@@ -483,22 +483,12 @@ def test_raw_comment_one_line(self):
483
483
'<!-- *foo* -->'
484
484
)
485
485
486
- # TODO: Decide behavior here. Python-Markdown current outputs:
487
- #
488
- # <!-- *foo* -->
489
- # <p><em>bar</em></p>
490
- #
491
- # But the reference implementation outputs:
492
- #
493
- # <p><!-- *foo* --><em>bar</em></p>
494
- #
495
- # As the raw HTML is not alone on the line, the reference implementation
496
- # considers it inline rather than block level. The behavior defined in
497
- # the test below is from the CommonMark spec, which we don't follow.
486
+ # Note: this is a change in behavior for Python_markdown but matches the reference implementation.
487
+ # Previous output was `<!-- *foo* -->\n<p><em>bar</em></p>`. Browsers render both the same.
498
488
def test_raw_comment_one_line_followed_by_text (self ):
499
489
self .assertMarkdownRenders (
500
490
'<!-- *foo* -->*bar*' ,
501
- '<!-- *foo* -->* bar* '
491
+ '<p>< !-- *foo* --><em> bar</em></p> '
502
492
)
503
493
504
494
def test_raw_multiline_comment (self ):
@@ -581,6 +571,17 @@ def test_raw_comment_nested(self):
581
571
)
582
572
)
583
573
574
+ def test_comment_in_code_block (self ):
575
+ self .assertMarkdownRenders (
576
+ ' <!-- *foo* -->' ,
577
+ self .dedent (
578
+ """
579
+ <pre><code><!-- *foo* -->
580
+ </code></pre>
581
+ """
582
+ )
583
+ )
584
+
584
585
def test_raw_processing_instruction_one_line (self ):
585
586
self .assertMarkdownRenders (
586
587
"<?php echo '>';' ?>" ,
@@ -662,20 +663,12 @@ def test_raw_declaration_one_line(self):
662
663
'<!DOCTYPE html>'
663
664
)
664
665
665
- # TODO: Decide correct behavior. This matches current behavior and Commonmark.
666
- # The reference implementation considers this inline not block level:
667
- #
668
- # <p><!DOCTYPE html><em>bar</em></p>
669
- #
670
- # But most implementations do this instead:
671
- #
672
- # <p><!DOCTYPE html><em>bar</em></p>
673
- #
674
- # Either makes sense, but the later seems more correct to me.
666
+ # Note: this is a change in behavior for Python_markdown but matches the reference implementation.
667
+ # Previous output was `<!DOCTYPE html>*bar*`.
675
668
def test_raw_declaration_one_line_followed_by_text (self ):
676
669
self .assertMarkdownRenders (
677
670
'<!DOCTYPE html>*bar*' ,
678
- '<!DOCTYPE html>* bar* '
671
+ '<p>< !DOCTYPE html><em> bar</em></p> '
679
672
)
680
673
681
674
def test_raw_multiline_declaration (self ):
@@ -702,20 +695,12 @@ def test_raw_cdata_one_line(self):
702
695
'<![CDATA[ document.write(">"); ]]>'
703
696
)
704
697
705
- # TODO: Decide correct behavior. This matches current behavior and Commonmark.
706
- # The reference implementation considers this inline not block level:
707
- #
708
- # <p><![CDATA[ document.write(">"); ]]><em>bar</em></p>
709
- #
710
- # But most implementations do this instead:
711
- #
712
- # <p><[CDATA[ document.write(“>”); ]]><em>bar</em></p>
713
- #
714
- # Either makes sense, but the later seems more correct to me.
698
+ # Note: this is a change in behavior for Python_markdown but matches the reference implementation.
699
+ # Previous output was `<![CDATA[ document.write(">"); ]]>*bar*`.
715
700
def test_raw_cdata_one_line_followed_by_text (self ):
716
701
self .assertMarkdownRenders (
717
702
'<![CDATA[ document.write(">"); ]]>*bar*' ,
718
- '<![CDATA[ document.write(">"); ]]>* bar* '
703
+ '<p>< ![CDATA[ document.write(">"); ]]><em> bar</em></p> '
719
704
)
720
705
721
706
def test_raw_multiline_cdata (self ):
0 commit comments