Skip to content

Commit

Permalink
Merge pull request #333 from jumale/fix-thematic-break
Browse files Browse the repository at this point in the history
Render ThematicBreak literal in markdown
  • Loading branch information
robinst committed Sep 12, 2024
2 parents e3795b2 + 103f002 commit 6bebfe2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ public void visit(Document document) {

@Override
public void visit(ThematicBreak thematicBreak) {
// Let's use ___ as it doesn't introduce ambiguity with * or - list item markers
writer.raw("___");
String literal = thematicBreak.getLiteral();
if (literal == null) {
// Let's use ___ as it doesn't introduce ambiguity with * or - list item markers
literal = "___";
}
writer.raw(literal);
writer.block();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ public void testThematicBreaks() {
// List item with hr -> hr needs to not use the same as the marker
assertRoundTrip("* ___\n");
assertRoundTrip("- ___\n");

// Preserve the literal
assertRoundTrip("----\n");
assertRoundTrip("*****\n");

// Apply fallback for null literal
ThematicBreak node = new ThematicBreak();
assertEquals("___", render(node));
}

@Test
Expand Down

0 comments on commit 6bebfe2

Please sign in to comment.