Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,11 @@ public void visit(Text text) {
break;
}
case '=': {
// Would be ambiguous with a Setext heading, escape
writer.raw("\\=");
literal = literal.substring(1);
// Would be ambiguous with a Setext heading, escape unless it's the first line in the block
if (text.getPrevious() != null) {
writer.raw("\\=");
literal = literal.substring(1);
}
break;
}
case '0':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ public void testEscaping() {
assertRoundTrip("\\## Test\n");
assertRoundTrip("\\#\n");
assertRoundTrip("Foo\n\\===\n");
// Only needs to be escaped after some text, not at beginning of paragraph
assertRoundTrip("===\n");
assertRoundTrip("a\n\n===\n");
// The beginning of the line within the block, so disregarding prefixes
assertRoundTrip("> \\- Test\n");
assertRoundTrip("- \\- Test\n");
Expand Down