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>
|
@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.
|
|
The raw value of tokens should ideally be the value of the markdown that rendered that token. If we replace it in the lexer raw will contain the replaced value instead |
|
Agreed, this also changes token.raw, and I missed that API effect in the tests. I'll add raw-preservation coverage and check a tokenizer-level approach before updating the PR. The current lexer-wide replacement shouldn't be treated as ready. |
|
I tested keeping NULs through tokenization and replacing them in token text afterward. That preserves raw for built-in tokens, but breaks documented extensions using custom fields or childTokens. The tree walk can also change caller-supplied tokens, including throwing on frozen ones, so I haven't pushed that prototype. What normalization/raw boundary do you intend here, especially for the source passed to extension tokenizers? I want to settle that before broadening the change. Existing CR-to-LF normalization would stay unchanged. |
|
Ideally someone using marked lexer to parse markdown into tokens should be able to recreate the original markdown by appending raw from the top level block tokens, and recreate any token's markdown from is child tokens. We do remove CR for legacy reasons but eventually I would like to get rid of that as well. If someone uses extensions we cannot guarantee this anyways since all extension can set anything in raw. So this rule only applies to marked without any extensions. |
Keep custom tokenizer normalization compatible and avoid rewriting prior lexer results. 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>
|
Updated in 4f09817. Built-in tokenization now preserves literal NULs in Added raw-reconstruction tests and frozen prior-result coverage for inline tokens and repeated |
There was a problem hiding this comment.
use .md & .html files for these tests
|
Merged master into this branch (aeee4be) to resolve a conflict in |
Add the .md and .html fixture pair requested in review. The .md holds the literal NUL bytes. Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
The web upload added a numeric prefix to the file name. It is re-added under the right name next. Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Drop the numeric prefix the web upload added, so the .html matches its .md pair. Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
The .md holds the literal NUL bytes, as in the earlier upload, under the right name. Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Replaced by the md and html fixtures. Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Summary
Replace literal U+0000 input characters with U+FFFD in parsed output, as required by CommonMark section 2.3 and GFM section 2.3, while preserving built-in token
rawvalues. Existing carriage-return handling is unchanged.Built-in tokenization retains the source characters, treats NUL like U+FFFD in the affected delimiter and destination rules, and normalizes semantic token fields afterward. Extensions and custom tokenizer overrides retain pre-tokenization source normalization, preserving their custom fields and declared child tokens. Normalization only visits tokens and link objects owned by the current call, including when a Lexer is reused with frozen prior results.
This is input normalization, not HTML sanitization or a security vulnerability claim. It does not decode additional entities or add a dependency. Preprocess hooks still receive original input. A custom
provideLexerstill owns its source. Direct low-levelblockTokenscalls remain unchanged.Tests
npm test: 2,107 spec tests and 272 unit tests pass, plus docs/build, UMD/CJS, types and lint.References:
Demo comparison for
[x](/a\0b)(the URL contains%00; NUL is invisible in the input editor):Contributor
Committer