From 809a075453f80643ef60ed511711ac0931dc563e Mon Sep 17 00:00:00 2001 From: Artem Yunusov Date: Sun, 24 Aug 2008 01:14:24 +0500 Subject: isBlockLevel function and HtmlBlockPreprocessor changed. more_comments test works fine now. --- markdown.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'markdown.py') 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) -- cgit v1.2.3