Skip to content

Commit

Permalink
fix for sirthias#222
Browse files Browse the repository at this point in the history
  • Loading branch information
vsch committed Feb 13, 2016
1 parent b18095e commit a239307
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ This function is also called for VerbatimNode from the DefaultVerbatimSerializer
preceded by alphanumeric for _ and as long as not surrounded by spaces for * instead
of only when preceded by spaces.

- Added allowing code fenced blocks with all blank lines

Version 1.6.0 (2015-09-18)
--------------------------
- Fixed collision between ANCHORLINKS and STRIKETHROUGH, WIKILINKS extensions (#161)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/pegdown/DefaultVerbatimSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void serialize(final VerbatimNode node, final Printer printer) {
printer.println().print("<pre><code").print(printer.preview(node, "code", attributes, false)).print('>');
String text = node.getText();
// print HTML breaks for all initial newlines
while (text.charAt(0) == '\n') {
while (!text.isEmpty() && text.charAt(0) == '\n') {
printer.print("<br/>");
text = text.substring(1);
}
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/org/pegdown/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,14 @@ public Rule FencedCodeBlock() {
Var<Integer> markerLength = new Var<Integer>();
return NodeSequence(
// vsch: test to see if what appears to be a code fence is just inline code
// vsch: change to accept code fence with all blank lines
CodeFence(markerLength),
TestNot(CodeFence(markerLength)), // prevent empty matches
ZeroOrMore(BlankLine(), text.append('\n')),
OneOrMore(TestNot(Newline(), CodeFence(markerLength)), ANY, text.append(matchedChar())),
Newline(),
push(new VerbatimNode(text.appended('\n').getString(), popAsString())),
OneOrMore(
TestNot(CodeFence(markerLength)),
ZeroOrMore(TestNot(Newline()), ANY, text.append(matchedChar())),
Sequence(Newline(), text.append(matchedChar()))
),
push(new VerbatimNode(text.getString(), popAsString())),
CodeFence(markerLength), drop()
);
}
Expand Down Expand Up @@ -1461,8 +1463,7 @@ ticks, Sp(),
FirstOf(
Sequence(TestNot('`'), Nonspacechar()),
Sequence(TestNot(ticks), OneOrMore('`')),
Sequence(TestNot(Sp(), ticks),
FirstOf(Spacechar(), Sequence(Newline(), TestNot(BlankLine()))))
Sequence(TestNot(Sp(), ticks), FirstOf(Spacechar(), Sequence(Newline(), TestNot(BlankLine()))))
)
),
push(new CodeNode(match())),
Expand Down

0 comments on commit a239307

Please sign in to comment.