aboutsummaryrefslogtreecommitdiffstats
path: root/mdx_headerid.py
diff options
context:
space:
mode:
authorArtem Yunusov <nedrlab@gmail.com>2008-08-02 04:08:13 +0500
committerArtem Yunusov <nedrlab@gmail.com>2008-08-02 04:08:13 +0500
commite54a1868b38c53073eb54df313962a105819b03e (patch)
tree9710069e572ed8e743be4a01096579a5e15f4ad4 /mdx_headerid.py
parent13d25f86f61bbce247a12b845c3675b57274a13e (diff)
downloadmarkdown-e54a1868b38c53073eb54df313962a105819b03e.tar.gz
markdown-e54a1868b38c53073eb54df313962a105819b03e.tar.bz2
markdown-e54a1868b38c53073eb54df313962a105819b03e.zip
Some other extensions ported to ElementTree, litle bugfix in core.
Diffstat (limited to 'mdx_headerid.py')
-rwxr-xr-x[-rw-r--r--]mdx_headerid.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/mdx_headerid.py b/mdx_headerid.py
index 2e658cd..2360071 100644..100755
--- a/mdx_headerid.py
+++ b/mdx_headerid.py
@@ -68,6 +68,7 @@ Dependencies:
"""
import markdown
+from markdown import etree
import re
from string import ascii_lowercase, digits, punctuation
@@ -106,15 +107,16 @@ class HeaderIdExtension (markdown.Extension) :
if m :
start_level, force_id = _get_meta()
level = len(m.group(1)) + start_level
- if level > 6: level = 6
- h = md.doc.createElement("h%d" % level)
- parent_elem.appendChild(h)
- for item in md._handleInline(m.group(2).strip()) :
- h.appendChild(item)
+ if level > 6:
+ level = 6
+ h = etree.Element("h%d" % level)
+ parent_elem.append(h)
+ inline = etree.SubElement(h, "inline")
+ inline.text = m.group(2).strip()
if m.group(3) :
- h.setAttribute('id', _unique_id(m.group(3)))
+ h.set('id', _unique_id(m.group(3)))
elif force_id:
- h.setAttribute('id', _create_id(m.group(2).strip()))
+ h.set('id', _create_id(m.group(2).strip()))
else :
message(CRITICAL, "We've got a problem header!")