@@ -486,7 +486,18 @@ def test_raw_comment_one_line(self):
486
486
'<!-- *foo* -->'
487
487
)
488
488
489
- # TODO: Confirm this is correct
489
+ # TODO: Decide behavior here. Python-Markdown current outputs:
490
+ #
491
+ # <!-- *foo* -->
492
+ # <p><em>bar</em></p>
493
+ #
494
+ # But the reference implementation outputs:
495
+ #
496
+ # <p><!-- *foo* --><em>bar</em></p>
497
+ #
498
+ # As the raw HTML is not alone on the line, the reference implementation
499
+ # considers it inline rather than block level. The behavior defined in
500
+ # the test below is from the CommonMark spec, which we don't follow.
490
501
def test_raw_comment_one_line_followed_by_text (self ):
491
502
self .assertMarkdownRenders (
492
503
'<!-- *foo* -->*bar*' ,
@@ -533,4 +544,223 @@ def test_raw_comment_with_blank_lines(self):
533
544
)
534
545
)
535
546
536
- # TODO: processing instruction, declaration, CDATA...
547
+ def test_raw_comment_indented (self ):
548
+ self .assertMarkdownRenders (
549
+ self .dedent (
550
+ """
551
+ <!--
552
+
553
+ *foo*
554
+
555
+ -->
556
+ """
557
+ ),
558
+ self .dedent (
559
+ """
560
+ <!--
561
+
562
+ *foo*
563
+
564
+ -->
565
+ """
566
+ )
567
+ )
568
+
569
+ def test_raw_processing_instruction_one_line (self ):
570
+ self .assertMarkdownRenders (
571
+ "<?php echo '>';' ?>" ,
572
+ "<?php echo '>';' ?>"
573
+ )
574
+
575
+ # This is inline as it is not on a line by itself.
576
+ def test_raw_processing_instruction_one_line_followed_by_text (self ):
577
+ self .assertMarkdownRenders (
578
+ "<?php echo '>';' ?>*bar*" ,
579
+ "<p><?php echo '>'; ' ?><em>bar</em></p>"
580
+ )
581
+
582
+ def test_raw_multiline_processing_instruction (self ):
583
+ self .assertMarkdownRenders (
584
+ self .dedent (
585
+ """
586
+ <?php
587
+ echo '>';'
588
+ ?>
589
+ """
590
+ ),
591
+ self .dedent (
592
+ """
593
+ <?php
594
+ echo '>';'
595
+ ?>
596
+ """
597
+ )
598
+ )
599
+
600
+ def test_raw_processing_instruction_with_blank_lines (self ):
601
+ self .assertMarkdownRenders (
602
+ self .dedent (
603
+ """
604
+ <?php
605
+
606
+ echo '>';'
607
+
608
+ ?>
609
+ """
610
+ ),
611
+ self .dedent (
612
+ """
613
+ <?php
614
+
615
+ echo '>';'
616
+
617
+ ?>
618
+ """
619
+ )
620
+ )
621
+
622
+ def test_raw_processing_instruction_indented (self ):
623
+ self .assertMarkdownRenders (
624
+ self .dedent (
625
+ """
626
+ <?php
627
+
628
+ echo '>';'
629
+
630
+ ?>
631
+ """
632
+ ),
633
+ self .dedent (
634
+ """
635
+ <?php
636
+
637
+ echo '>';'
638
+
639
+ ?>
640
+ """
641
+ )
642
+ )
643
+
644
+ def test_raw_declaration_one_line (self ):
645
+ self .assertMarkdownRenders (
646
+ '<!DOCTYPE html>' ,
647
+ '<!DOCTYPE html>'
648
+ )
649
+
650
+ # TODO: Decide correct behavior. This matches current behavior and Commonmark.
651
+ # The reference implementation considers this inline not block level:
652
+ #
653
+ # <p><!DOCTYPE html><em>bar</em></p>
654
+ #
655
+ # But most implementations do this instead:
656
+ #
657
+ # <p><!DOCTYPE html><em>bar</em></p>
658
+ #
659
+ # Either makes sense, but the later seems more correct to me.
660
+ def test_raw_declaration_one_line_followed_by_text (self ):
661
+ self .assertMarkdownRenders (
662
+ '<!DOCTYPE html>*bar*' ,
663
+ '<!DOCTYPE html>*bar*'
664
+ )
665
+
666
+ def test_raw_multiline_declaration (self ):
667
+ self .assertMarkdownRenders (
668
+ self .dedent (
669
+ """
670
+ <!DOCTYPE html PUBLIC
671
+ "-//W3C//DTD XHTML 1.1//EN"
672
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
673
+ """
674
+ ),
675
+ self .dedent (
676
+ """
677
+ <!DOCTYPE html PUBLIC
678
+ "-//W3C//DTD XHTML 1.1//EN"
679
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
680
+ """
681
+ )
682
+ )
683
+
684
+ def test_raw_cdata_one_line (self ):
685
+ self .assertMarkdownRenders (
686
+ '<![CDATA[ document.write(">"); ]]>' ,
687
+ '<![CDATA[ document.write(">"); ]]>'
688
+ )
689
+
690
+ # TODO: Decide correct behavior. This matches current behavior and Commonmark.
691
+ # The reference implementation considers this inline not block level:
692
+ #
693
+ # <p><![CDATA[ document.write(">"); ]]><em>bar</em></p>
694
+ #
695
+ # But most implementations do this instead:
696
+ #
697
+ # <p><[CDATA[ document.write(“>”); ]]><em>bar</em></p>
698
+ #
699
+ # Either makes sense, but the later seems more correct to me.
700
+ def test_raw_cdata_one_line_followed_by_text (self ):
701
+ self .assertMarkdownRenders (
702
+ '<![CDATA[ document.write(">"); ]]>*bar*' ,
703
+ '<![CDATA[ document.write(">"); ]]>*bar*'
704
+ )
705
+
706
+ def test_raw_multiline_cdata (self ):
707
+ self .assertMarkdownRenders (
708
+ self .dedent (
709
+ """
710
+ <![CDATA[
711
+ document.write(">");
712
+ ]]>
713
+ """
714
+ ),
715
+ self .dedent (
716
+ """
717
+ <![CDATA[
718
+ document.write(">");
719
+ ]]>
720
+ """
721
+ )
722
+ )
723
+
724
+ def test_raw_cdata_with_blank_lines (self ):
725
+ self .assertMarkdownRenders (
726
+ self .dedent (
727
+ """
728
+ <![CDATA[
729
+
730
+ document.write(">");
731
+
732
+ ]]>
733
+ """
734
+ ),
735
+ self .dedent (
736
+ """
737
+ <![CDATA[
738
+
739
+ document.write(">");
740
+
741
+ ]]>
742
+ """
743
+ )
744
+ )
745
+
746
+ def test_raw_cdata_indented (self ):
747
+ self .assertMarkdownRenders (
748
+ self .dedent (
749
+ """
750
+ <![CDATA[
751
+
752
+ document.write(">");
753
+
754
+ ]]>
755
+ """
756
+ ),
757
+ self .dedent (
758
+ """
759
+ <![CDATA[
760
+
761
+ document.write(">");
762
+
763
+ ]]>
764
+ """
765
+ )
766
+ )
0 commit comments