fix: align indented code block detection with CommonMark - #1512
Open
amansri-30 wants to merge 1 commit into
Open
amansri-30 wants to merge 1 commit into
amansri-30 wants to merge 1 commit into
Conversation
Only 4-space (or tab) indentation after a blank line denotes an indented code block. 2-space indented lines are paragraph/list continuations and were previously emitted raw, producing invalid JS (e.g. SyntaxError: Unexpected identifier) when running markdown docs with indented prose inside list items. Closes google#1388
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Fixes #1388
What
transformMarkdown()now detects indented code blocks per CommonMark: only indentation of 4+ spaces (or a tab) after a blank line is treated as code. Previously any 2+ space indented line was emitted raw, which broke markdown docs containing indented prose inside list items:- on localhost This assumes you have a local node running ...was emitted verbatim as JS, producing
SyntaxError: Unexpected identifier 'assumes'(repro:template-ethereum-contractsREADME).Now such 2-space paragraph/list continuations are handled as text (commented out), while fenced code blocks indented up to 3 spaces inside the same list item still run.
Checklist
npm run buildlocally: the repo's build/test scripts rely on POSIXrmand derive paths vianew URL(import.meta.url).pathname, which on Windows yieldsC:\C:\...(pre-existing portability issue). GitHub CI runs the full build +npm teston Linux.test/md.test.tspasses locally (7/7) vianode --experimental-transform-types --test test/md.test.ts; added a regression test for this issue. Fullnpm testblocked on Windows by the same pre-existing path bugs (license/madge/size hooks).