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. |
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.
Marked version: master c6b22e8 (18.2.1)
Markdown flavor: CommonMark / GFM
Description
Code spans and backslash escapes in an image description lose literal entity text when the flattened text is escaped for the alt attribute.
For
, current master emitsalt="&", whose DOM value is&. The code span contains the literal text&, so the expected HTML isalt="&amp;", whose DOM value is&. Numeric-looking entities and escaped ampersands have the same problem. This changes the actual alt text, not only the spelling of equivalent HTML entities.Before image text is flattened, copy its inline tokens and encode literal code-span and escape text. Keep the existing attribute escaping. Nested formatting, links and images are handled through their child tokens without mutating the original token tree.
The exported TextRenderer and the parser.textRenderer field keep their existing plain-text behavior outside image rendering. Image rendering still uses that renderer, including custom methods; within that image-only call, literal code/escape token copies now contain encoded text. Tests cover the plain-text API, a custom strong renderer, and token immutability.
Seven exact-output cases cover named/numeric-looking code literals, escaped ampersands, normal entity controls and nested formatting/images. The decoded alt values agree with CommonMark.
Validation on Node 22.23.4:
npm testpassed, including builds/docs, UMD/CJS, types and lint.git diff --checkpassed.Contributor
Committer