fix(md): require 4+ spaces for indented code blocks (CommonMark)#1471
Open
kiwigitops wants to merge 3 commits into
Open
fix(md): require 4+ spaces for indented code blocks (CommonMark)#1471kiwigitops wants to merge 3 commits into
kiwigitops wants to merge 3 commits into
Conversation
Collaborator
|
@antongolub LGTM |
Collaborator
|
I'd prefer more explicit form: |
Author
|
Updated in 5b2f8e5 to use the explicit regex form you suggested: /^( {4,}|\t)/ |
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.
Fixes #1388.
Problem
transformMarkdown()insrc/md.tstreats any line indented with 2 or more spaces (after a blank line) as a markdown indented code block — i.e. raw JS to execute. CommonMark requires 4 or more spaces for an indented code block.The 2-space cutoff incorrectly captures list-item continuation lines, which are conventionally indented 2 spaces to align with the content after
-. Those continuation lines are prose, not code, but the parser hands them to the JS engine as raw code and the script blows up withSyntaxError: Unexpected identifier '<word>'.The reporter's case is a README with prose continuation under a list item followed by a fenced shell block. The prose line begins with two spaces, so the old regex treated it as executable code.
Fix
Aligns the indented-code-block threshold with CommonMark: 4+ spaces or 1 tab. Tab-indented blocks keep working unchanged.
Test plan