aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuri Takhteyev <yuri@freewisdom.org>2006-05-17 07:35:30 +0000
committerYuri Takhteyev <yuri@freewisdom.org>2006-05-17 07:35:30 +0000
commit413e484987756659ffdbf4c410b566c6bc748eff (patch)
tree60e48bff40f32f0a17c07de3ca539f3f189cffcb
parent0d1db7d827e3c986f1994f567b8910c292bfeed6 (diff)
downloadmarkdown-413e484987756659ffdbf4c410b566c6bc748eff.tar.gz
markdown-413e484987756659ffdbf4c410b566c6bc748eff.tar.bz2
markdown-413e484987756659ffdbf4c410b566c6bc748eff.zip
Another revision for for multi-paragraph html (from hukeli)
-rw-r--r--markdown.py31
1 files changed, 24 insertions, 7 deletions
diff --git a/markdown.py b/markdown.py
index d1f0605..ff81f4a 100644
--- a/markdown.py
+++ b/markdown.py
@@ -339,12 +339,20 @@ class HtmlBlockPreprocessor :
def _get_right_tag(self, left_tag, block):
- return block.rstrip()[-len(left_tag)-2:-1].strip().lower()
+ return block.rstrip()[-len(left_tag)-2:-1].lower()
def _equal_tags(self, left_tag, right_tag):
if ("/" + left_tag) == right_tag:
return True
- return False
+ elif left_tag == right_tag[1:] \
+ and right_tag[0] != "<":
+ return True
+ else:
+ return False
+
+ def _is_oneliner(self, tag):
+ return (tag in ['hr', 'hr/'])
+
def run (self, lines) :
new_blocks = []
@@ -367,13 +375,22 @@ class HtmlBlockPreprocessor :
left_tag = self._get_left_tag(block)
right_tag = self._get_right_tag(left_tag, block)
- if not (is_block_level(left_tag)
- or block[1] in ["!", "?", "@", "%"]):
+ if not (is_block_level(left_tag) \
+ or block[1] in ["!", "?", "@", "%"]):
new_blocks.append(block)
continue
-
- if (block.rstrip().endswith(">") and
- self._equal_tags(left_tag, right_tag)):
+
+ if self._is_oneliner(left_tag):
+ new_blocks.append(block.strip())
+ continue
+
+ if block[1] == "!":
+ # is comment block
+ left_tag = "--"
+ right_tag = self._get_right_tag(left_tag, block)
+
+ if block.rstrip().endswith(">") \
+ and self._equal_tags(left_tag, right_tag):
new_blocks.append(
self.stash.store(block.strip()))
continue