Repository navigation
Conversation
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
|
@hakarrr is attempting to deploy a commit to the MarkedJS Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
|
Merged master into this branch (41a24d0) to resolve a conflict in |
There was a problem hiding this comment.
Only keep tests that are needed to verify that it is working
…mmonmark.html Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
…mmonmark.md Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Move the remaining separator, pedantic, and list-replacement cases from test/unit/marked.test.js into spec fixtures, per review. Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
UziTech
left a comment
There was a problem hiding this comment.
Thanks for the fix! The core ATX heading ASCII-whitespace change in src/rules.ts looks good (passes recheck, preserves benchmark parity, and keeps bundle size growth minimal), and the new fixtures verify the behavior cleanly.
A few things need to be addressed before merging:
-
src/Tokenizer.ts(lines 353 & 383) — StalelastTokenwhen skipping trailingspacetokens
WhenlastTokenIndex < tokens.length - 1, both the nestedblockquoteandlistcontinuation branches still set:this.lexer.state.lastToken = tokens.at(-2);
That points to
oldToken(or anotherspacetoken) instead of the preceding sibling token. Please update both totokens[lastTokenIndex - 1]. -
src/Tokenizer.ts(lines 357 & 388) — Orphaned trailingspacetoken(s) after the replaced block
Assigningtokens[lastTokenIndex] = newTokenleaves the skipped trailingspacetoken(s) attokens[lastTokenIndex + 1..]positioned after the continued block in the AST (for example,marked.lexer('> - item \t\n#text')leaves{ type: 'space', raw: ' \t' }after the list, and> - item \t\nlazy1\n> lazy2leaves aspacetoken between the list and<p>lazy2</p>).- Also note on the nested
blockquotebranch (line 368) thattext.substring(0, text.length - oldToken.text.length) + newToken.textassumestextends witholdToken.text, which is false if trailing whitespace tokens followedoldToken. - And for
> - item \n#text,oldToken.rawexcludes the trailing' 'stored in thespacetoken, so replaying without it drops the<br>hard break. - Please remove/truncate the consumed trailing
spacetoken(s) when replacingtokens[lastTokenIndex](e.g.,tokens.splice(lastTokenIndex, tokens.length - lastTokenIndex, newToken)), or include the trailing space raw when replaying if preserving hard line breaks.
- Also note on the nested
-
test/specs/new/atx_heading_ascii_whitespace_contexts_commonmark.md&atx_heading_ascii_whitespace_contexts_gfm.md— Duplicate CommonMark/GFM fixture
Both files contain the exact same 26-line Markdown: 7 of the 8 blocks produce identical output in CommonMark and GFM, and the 8th block is a GFM table (which just tests paragraph continuation again undergfm: false). Please deduplicate these — e.g., keep only theblockNormal-specificparagraph/lheadingcases in the CommonMark fixture if needed, or consolidate the shared cases into a single fixture. -
src/rules.ts(lines 294–300, minor)
Prefer theedit()helper overnew RegExp(...source.replaceAll(...))forlegacyLheadingandblockPedantic.blockquote(or simplify if not needed).
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Fix missing closing brace and add newline at end of file. Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
|
Thanks for the review, @UziTech. Each point from your review is addressed in the latest commits:
Could you re-review when you get a chance? |
ec1236c to
e38ec08
Compare
Marked version: master (
c6b22e89)Markdown flavor: CommonMark and GFM
Description
An ATX heading's opening hashes must be followed by an ASCII space, tab, or the end of the line (CommonMark 4.2). The modern heading rule and its interruption checks currently use
\s, so a nonbreaking space, vertical tab, form feed, or other Unicode whitespace can incorrectly open a heading or end a paragraph, list item, setext heading, or table.For example,
#\u00a0text(with a literal nonbreaking space) should stay a paragraph, but master produces<h1>text</h1>.Use the same ASCII whitespace boundary for modern ATX openers and their interruption checks. Keep the compiled pedantic block rules and pedantic continuation path unchanged.
The narrower interruption boundary also exposes a blockquote continuation bug: trailing
spacetokens can hide the last substantive block. Inspect that block before accepting lazy text, and replace a continued nested list or blockquote at its own token index rather than replacing the trailing space. This also fixes some existing non-Unicode continuation cases.Demo: master / CommonMark. Master produces a heading; CommonMark produces a paragraph.
Tests
npm test: 2,043 spec tests and 260 unit tests pass, plus UMD, CJS, types and lint.npm run build:resetpasses. Two trailing-space warnings in fixture inputs are intentional reproductions.recheck:block.normal.headingandblock.gfm.headingsafe.These probes are bounded regression checks, not a claim of full parser conformance.
Contributor
Committer