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 @@ -206,6 +206,13 @@ private boolean destination(Scanner scanner) {
} else if (whitespace == 0) {
// spec: The title must be separated from the link destination by whitespace
return false;
} else {
char c = scanner.peek();
if (c != '"' && c != '\'' && c != '(') {
// Other text after the destination on the same line, so this is not a link
// reference definition (and not the start of another one either)
return false;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole code is getting a bit unwieldy, might be time for a full rewrite at some point..

}
}

state = State.START_TITLE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ void testDestinationInvalid() {
assertParagraph("[foo]: <bar<>");
}

@Test
void testDestinationFollowedByOtherText() {
assertParagraph("[foo]: /url bar");
// Another definition-like text on the same line must not be parsed as a definition
assertParagraph("[foo]: /url [bar]: /url2");
assertParagraph("[foo]: /url``_> [bar]: /url2");
}

@Test
void testTitle() {
parse("[foo]: /url 'title'");
Expand Down
Loading