diff options
author | Waylan Limberg <waylan.limberg@icloud.com> | 2015-03-14 17:15:06 -0400 |
---|---|---|
committer | Waylan Limberg <waylan.limberg@icloud.com> | 2015-03-14 17:15:06 -0400 |
commit | 8111fd3d80f5a9a530323338ac07910bc9e4f653 (patch) | |
tree | 8926552a69d99ef10d1e8d6478d5bd9668830001 | |
parent | 59bb9afb86d71b258e54c7099beb094f8523ddb7 (diff) | |
download | markdown-8111fd3d80f5a9a530323338ac07910bc9e4f653.tar.gz markdown-8111fd3d80f5a9a530323338ac07910bc9e4f653.tar.bz2 markdown-8111fd3d80f5a9a530323338ac07910bc9e4f653.zip |
Add Comment support to toc.
A etree can contain Comments, PIs or other Elements which do not have
a string for a tag. Must always check that a tag is a string before
doing string processing on it. Otherwise, things will crash.
-rw-r--r-- | markdown/extensions/toc.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py index fdfa687..b3cf898 100644 --- a/markdown/extensions/toc.py +++ b/markdown/extensions/toc.py @@ -17,7 +17,7 @@ from __future__ import absolute_import from __future__ import unicode_literals from . import Extension from ..treeprocessors import Treeprocessor -from ..util import etree, parseBoolValue, AMP_SUBSTITUTE, HTML_PLACEHOLDER_RE +from ..util import etree, parseBoolValue, AMP_SUBSTITUTE, HTML_PLACEHOLDER_RE, string_type import re import unicodedata @@ -231,7 +231,7 @@ class TocTreeprocessor(Treeprocessor): toc_tokens = [] for el in doc.iter(): - if self.header_rgx.match(el.tag): + if isinstance(el.tag, string_type) and self.header_rgx.match(el.tag): self.set_level(el) text = ''.join(el.itertext()).strip() |