diff options
Diffstat (limited to 'markdown')
-rw-r--r-- | markdown/extensions/attr_list.py | 8 | ||||
-rw-r--r-- | markdown/extensions/headerid.py | 10 |
2 files changed, 8 insertions, 10 deletions
diff --git a/markdown/extensions/attr_list.py b/markdown/extensions/attr_list.py index 36f3e3a..8734e9f 100644 --- a/markdown/extensions/attr_list.py +++ b/markdown/extensions/attr_list.py @@ -74,7 +74,6 @@ class AttrListTreeprocessor(markdown.treeprocessors.Treeprocessor): def run(self, doc): for elem in doc.getiterator(): - #import pdb; pdb.set_trace() if isBlockLevel(elem.tag): # Block level: check for attrs on last line of text RE = self.BLOCK_RE @@ -131,12 +130,7 @@ class AttrListTreeprocessor(markdown.treeprocessors.Treeprocessor): class AttrListExtension(markdown.extensions.Extension): def extendMarkdown(self, md, md_globals): - if 'headerid' in md.treeprocessors.keys(): - # insert after 'headerid' treeprocessor - md.treeprocessors.add('attr_list', AttrListTreeprocessor(md), '>headerid') - else: - # insert after 'inline' treeprocessor - md.treeprocessors.add('attr_list', AttrListTreeprocessor(md), '>inline') + md.treeprocessors.add('attr_list', AttrListTreeprocessor(md), '>inline') def makeExtension(configs={}): diff --git a/markdown/extensions/headerid.py b/markdown/extensions/headerid.py index 2d18c15..1d158f9 100644 --- a/markdown/extensions/headerid.py +++ b/markdown/extensions/headerid.py @@ -133,7 +133,7 @@ class HeaderIdTreeprocessor(markdown.treeprocessors.Treeprocessor): if elem.tag in ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']: if force_id: if "id" in elem.attrib: - id = elem.id + id = elem.get('id') else: id = slugify(u''.join(itertext(elem)), sep) elem.set('id', unique(id, self.IDs)) @@ -183,8 +183,12 @@ class HeaderIdExtension (markdown.Extension): self.processor = HeaderIdTreeprocessor() self.processor.md = md self.processor.config = self.getConfigs() - # Replace existing hasheader in place. - md.treeprocessors.add('headerid', self.processor, '>inline') + if 'attr_list' in md.treeprocessors.keys(): + # insert after attr_list treeprocessor + md.treeprocessors.add('headerid', self.processor, '>attr_list') + else: + # insert after 'inline' treeprocessor. + md.treeprocessors.add('headerid', self.processor, '>inline') def reset(self): self.processor.IDs = [] |