diff --git a/mkdcomments.py b/mkdcomments.py index d96f1f7..4db4746 100644 --- a/mkdcomments.py +++ b/mkdcomments.py @@ -10,12 +10,9 @@ class CommentsExtension(Extension): def extendMarkdown(self, md): md.registerExtension(self) - md.preprocessors.register( - CommentMunger(md), "comment_munger", 21) - md.preprocessors.register( - CommentRemover(md), "comment_remover", 19) - md.postprocessors.register( - RawCommentReplacer(md), "raw_comment_replacer", 29) + md.preprocessors.register(CommentMunger(md), "comment_munger", 21) + md.preprocessors.register(CommentRemover(md), "comment_remover", 19) + md.postprocessors.register(RawCommentReplacer(md), "raw_comment_replacer", 29) class CommentMunger(Preprocessor): @@ -58,7 +55,25 @@ def _unmultiliner(self, line): class RawCommentReplacer(Postprocessor): def run(self, text): - return re.sub(PREFIX_PLACEHOLDER, ' + 1. Kira second + 1. Kira third + """ + expected_result = """\ +
    +
  1. Kira first
  2. +
  3. Kira second
  4. +
  5. Kira third
  6. +
""" + self.assertExpectedMarkdown(md_input, expected_result) + + def test_comments_between_list_items_with_blank_lines(self): + """Test the case where a comment and blank lines between items inside the list.""" + md_input = """\ + 1. Kira first + + + + 1. Kira second + 1. Kira third + """ + expected_result = """\ +
    +
  1. Kira first
  2. +
  3. Kira second
  4. +
  5. Kira third
  6. +
""" + self.assertExpectedMarkdown(md_input, expected_result) + + def test_multiline_comments_between_list_items(self): + """Test the case where a multiline comment and blank lines between the items inside the list.""" + md_input = """\ + 1. Kira first + + + + 1. Kira second + 1. Kira third + """ + expected_result = """\ +
    +
  1. Kira first
  2. +
  3. Kira second
  4. +
  5. Kira third
  6. +
""" + self.assertExpectedMarkdown(md_input, expected_result) + def test_comments_in_html(self): """ See issue #2. """ md_input = """\