diff options
author | Artem Yunusov <nedrlab@gmail.com> | 2008-08-24 01:14:24 +0500 |
---|---|---|
committer | Artem Yunusov <nedrlab@gmail.com> | 2008-08-24 01:14:24 +0500 |
commit | 809a075453f80643ef60ed511711ac0931dc563e (patch) | |
tree | 3d1484afb98aeaafb13fd243a715b2a73f824a4c /markdown.py | |
parent | 9eab105464c3aa938feea043fdac19ddb6e224cd (diff) | |
download | markdown-809a075453f80643ef60ed511711ac0931dc563e.tar.gz markdown-809a075453f80643ef60ed511711ac0931dc563e.tar.bz2 markdown-809a075453f80643ef60ed511711ac0931dc563e.zip |
isBlockLevel function and HtmlBlockPreprocessor changed. more_comments test works fine now.
Diffstat (limited to 'markdown.py')
-rwxr-xr-x | markdown.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/markdown.py b/markdown.py index a44ae66..ba1c687 100755 --- a/markdown.py +++ b/markdown.py @@ -181,19 +181,14 @@ INLINE_PLACEHOLDER_SUFFIX = ETX AMP_SUBSTITUTE = STX+"amp"+ETX +BLOCK_LEVEL_ELEMENTS = re.compile('p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del|hr|hr/|style') -BLOCK_LEVEL_ELEMENTS = ['p', 'div', 'blockquote', 'pre', 'table', - 'dl', 'ol', 'ul', 'script', 'noscript', - 'form', 'fieldset', 'iframe', 'math', 'ins', - 'del', 'hr', 'hr/', 'style'] - -def isBlockLevel (tag): +def isBlockLevel(tag): """ Used by HTMLBlockPreprocessor to check if a given tag is a block level element. """ - return ( (tag in BLOCK_LEVEL_ELEMENTS) or - (tag[0] == 'h' and tag[1] in "0123456789") ) + return BLOCK_LEVEL_ELEMENTS.match(tag) def codepoint2name(code): @@ -369,8 +364,14 @@ class HtmlBlockPreprocessor(TextPreprocessor): continue else: #if not block[1] == "!": # if is block level tag and is not complete - items.append(block.strip()) - in_tag = True + + if isBlockLevel(left_tag): + items.append(block.strip()) + in_tag = True + else: + new_blocks.append( + self.stash.store(block.strip())) + continue new_blocks.append(block) |