Skip to content

Fix parser ignoring everything between reference link text and its label#177

Open
spacedvoid wants to merge 1 commit intoJetBrains:masterfrom
spacedvoid:master
Open

Fix parser ignoring everything between reference link text and its label#177
spacedvoid wants to merge 1 commit intoJetBrains:masterfrom
spacedvoid:master

Conversation

@spacedvoid
Copy link

The cause is that TokenCache.RangesListIterator skips indexes between text ranges without informing the user. So, we don't know whether the two tokens between an advance is right next to each other without an additional check.

The change to ReferenceLinkParser is, for both full and short reference links, they now check whether the opening bracket of the link label is right next to the closing bracket of the link text.

This change effectively disables the behavior that allows a newline between the link text and its label, so it is removed. The tests from ea79689 and referenceLinks use this behavior, so they are also changed. This behavior is explicitly prohibited according to the spec, too:
https://spec.commonmark.org/0.31.2/#example-543
https://spec.commonmark.org/0.31.2/#example-556

Some new tests were added to referenceLinks to check the fixed behavior, and the relevant ignored spec tests were re-enabled.

Only the tests from gradlew mingwX64Test were checked since all other platforms failed most tests for an unknown reason, even for the current head.

This will fix KTIJ-35552 and the original Dokka issue Kotlin/dokka#4234.

While this also fixes KTIJ-35278, it should be closed and reopened as another issue for the second case(no space between unlabeled and labeled link) as the current parsing system does not consider link destinations when parsing the links.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant