FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix code spans after an unclosed backtick string by TanbirRamim · Pull Request #459 · commonmark/commonmark-java · GitHub

Repository navigation

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ public ParsedInline tryParse(InlineParserState inlineParserState) {
while (scanner.find('`') > 0) {
var beforeClosing = scanner.position();
var length = scanner.matchMultiple('`');
// Keep track of last position of backticks run of this length
backtickPositions.put(length, beforeClosing);
// Keep track of last position of backticks run of this length. Once the whole input
// has been scanned, the map already holds the last positions, so don't overwrite them
// with earlier ones.
if (!scannedToEnd) {
backtickPositions.put(length, beforeClosing);
}
if (length == openingLength) {
Code node = new Code();

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -456,4 +456,11 @@ public void emphasisAfterHardLineBreak() {
Foo</p>
""");
}

@Test
public void codeSpansAfterUnclosedBackticks() {
assertRendering("`` `a` `c`", "<p>`` <code>a</code> <code>c</code></p>\n");
assertRendering(
"`` `a` `c` `e`", "<p>`` <code>a</code> <code>c</code> <code>e</code></p>\n");
}
}

Back | FazBrowse Home | New Git URL