File tree Expand file tree Collapse file tree
main/java/org/commonmark/renderer/markdown
test/java/org/commonmark/renderer/markdown Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -366,9 +366,11 @@ public void visit(Text text) {
366366 break ;
367367 }
368368 case '=' : {
369- // Would be ambiguous with a Setext heading, escape
370- writer .raw ("\\ =" );
371- literal = literal .substring (1 );
369+ // Would be ambiguous with a Setext heading, escape unless it's the first line in the block
370+ if (text .getPrevious () != null ) {
371+ writer .raw ("\\ =" );
372+ literal = literal .substring (1 );
373+ }
372374 break ;
373375 }
374376 case '0' :
Original file line number Diff line number Diff line change @@ -189,6 +189,9 @@ public void testEscaping() {
189189 assertRoundTrip ("\\ ## Test\n " );
190190 assertRoundTrip ("\\ #\n " );
191191 assertRoundTrip ("Foo\n \\ ===\n " );
192+ // Only needs to be escaped after some text, not at beginning of paragraph
193+ assertRoundTrip ("===\n " );
194+ assertRoundTrip ("a\n \n ===\n " );
192195 // The beginning of the line within the block, so disregarding prefixes
193196 assertRoundTrip ("> \\ - Test\n " );
194197 assertRoundTrip ("- \\ - Test\n " );
You can’t perform that action at this time.
0 commit comments