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 @@ -370,9 +370,11 @@ public void visit(Text text) {
370370 break ;
371371 }
372372 case '=' : {
373- // Would be ambiguous with a Setext heading, escape
374- writer .raw ("\\ =" );
375- literal = literal .substring (1 );
373+ // Would be ambiguous with a Setext heading, escape unless it's the first line in the block
374+ if (text .getPrevious () != null ) {
375+ writer .raw ("\\ =" );
376+ literal = literal .substring (1 );
377+ }
376378 break ;
377379 }
378380 case '0' :
Original file line number Diff line number Diff line change @@ -197,6 +197,9 @@ public void testEscaping() {
197197 assertRoundTrip ("\\ ## Test\n " );
198198 assertRoundTrip ("\\ #\n " );
199199 assertRoundTrip ("Foo\n \\ ===\n " );
200+ // Only needs to be escaped after some text, not at beginning of paragraph
201+ assertRoundTrip ("===\n " );
202+ assertRoundTrip ("a\n \n ===\n " );
200203 // The beginning of the line within the block, so disregarding prefixes
201204 assertRoundTrip ("> \\ - Test\n " );
202205 assertRoundTrip ("- \\ - Test\n " );
You can’t perform that action at this time.
0 commit comments