Fix parser ignoring everything between reference link text and its label#177
Open
spacedvoid wants to merge 1 commit intoJetBrains:masterfrom
Open
Fix parser ignoring everything between reference link text and its label#177spacedvoid wants to merge 1 commit intoJetBrains:masterfrom
spacedvoid wants to merge 1 commit intoJetBrains:masterfrom
Conversation
Fixes KTIJ-35552 and KTIJ-35278
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The cause is that
TokenCache.RangesListIteratorskips 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
ReferenceLinkParseris, 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
ea79689andreferenceLinksuse 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
referenceLinksto check the fixed behavior, and the relevant ignored spec tests were re-enabled.Only the tests from
gradlew mingwX64Testwere 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.