Repository navigation
Conversation
…tions A paragraph whose lines so far are all link reference definitions is still an open paragraph, so an ordered list not starting with 1 or an empty list item can't interrupt it. ListBlockParser checked for remaining paragraph lines instead, so e.g. "[foo]: /url\n2. a" was rendered as a list starting at 2 instead of a paragraph "2. a". Check whether the matched block is a paragraph, like HtmlBlockParser does for type 7. This matches commonmark.js 0.31.2.
This branch has not been deployed
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.
An ordered list that doesn't start with 1, or an empty list item, can't interrupt a paragraph (spec section 5.2). This wasn't applied when the paragraph so far only had link reference definitions:
rendered as
<ol start="2"><li>a</li></ol>instead of<p>2. a</p>. The same happened for an empty item ([foo]: /urlthen-), after a definition with a title, and inside a block quote.ListBlockParser.Factorydecided whether it was in a paragraph with!matchedBlockParser.getParagraphLines().isEmpty().getParagraphLines()leaves out the lines already parsed as definitions, so for a paragraph with only definitions it was empty, and the list was allowed to interrupt it. But that paragraph is still open, and the next line is paragraph continuation text, as spec example 217 shows for===after a definition (it stays in the paragraph instead of becoming a setext heading). The check now looks at whether the matched block is aParagraph, asHtmlBlockParseralready does for type 7.commonmark.js 0.31.2 renders all the new test cases the same way.
SpecialInputTest#listCanNotInterruptParagraphWithOnlyLinkReferenceDefinitionsfails without the change.mvn install(all modules) andmvn spotless:check(JDK 17) pass.For context, this came up when comparing the HTML output of commonmark-java with commonmark.js 0.31.2 on 150,000 generated inputs. With the change, the two inputs whose output changed now match commonmark.js, and no other output changed.