Repository navigation
Fix container fence when content has a line of colons - #18
Open
builtbysharath wants to merge 1 commit into
Open
builtbysharath wants to merge 1 commit into
builtbysharath wants to merge 1 commit into
Conversation
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.
Initial checklist
Description of changes
Closes remarkjs/remark-directive#25.
The fence of a container directive was sized only from the container directives nested in it. A line of colons elsewhere in the content, such as
:::in fenced code, also closes the container when it has at least as many colons as the fence. So this round trip:was serialized with a
:::fence, which the:::line in the code then closes.As suggested in remarkjs/remark-directive#25 (comment), the container now looks at the lines of its serialized content. It makes the fence longer than the longest sequence of colons on any line that has only spaces and tabs around it, which is what micromark accepts as a closing fence. Lines with colons and other characters, such as
:::b, can't close the container and don't change the fence. The nesting count is kept, so output for nested containers, including those in block quotes, is unchanged. Because the lines are those of the serialized content, an inner container whose fence grew pushes the outer fence up too.The content has to be serialized before the fence size is known, so when the fence grows, the extra colons are prepended to the opening afterwards. The tracker position given to the label doesn't include those extra colons.
Tests cover code with a line of colons, colons with spaces and tabs around them, colons followed by other characters (unchanged), an inner container with code, and the round trip above.
npm testpasses, including 100% coverage.