Repository navigation
fix(md): parse indented fenced code blocks inside lists (fixes #1389) - #1518
Closed
swaraj792725 wants to merge 1 commit into
Closed
swaraj792725 wants to merge 1 commit into
swaraj792725 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.
Fixes #1389
Description
When fenced code blocks (```bash or ```js) are nested inside lists, list items, or blocks, they are often indented with 4 or more spaces.
Previously,
fenceRerestricted the opening fence indentation to{0,3}spaces, which caused code fences indented with 4+ spaces to fail fence recognition, fall into the indented code block branch, and emit raw markdown backticks into the generated JavaScript file (e.g.```bash ... ```), resulting in syntax errors orTypeError: $(...) is not a functionduring script execution.This PR:
fenceReto accept any leading space indentation ((?<indent> *)) so indented code fences nested in lists are recognized.endReto match closing code fences with any leading space indentation (^ *${fenceChar}{${g.fence.length},}[ \t]*$).stripRemechanism to strip the fence's indentation level from code lines while preserving relative indentation inside the code.test/md.test.tsverifying that indented code fences inside lists are transformed to executable commands without emitting raw markdown fences.