Repository navigation
[lexical-mdast] Bug Fix: Escape the dot of www. so the characters after it import as typed #9956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@lexical/mdast': patch | ||
| --- | ||
|
|
||
| [fix] With `MdastAutolinkLiteralExtension`, export escapes the `.` of `www.` in text whatever follows it, so the characters after it are read back as typed: `www.世` before bold `!` was written as `www.世**!**` and read back as a link to `http://www.世`, then `;` and `!` | ||
|
|
||
| Verify: export snapshots of text with `www.` before the marker of a format or a link, before a non-ASCII character beside formatting, or before punctuation that the export escapes, such as `www\.**x**` (formerly `www.**x**`), `www\.世**!**` (formerly `www.世**!**`) or `www\.\*x` (formerly `www.\*x`). Plain `www.example.com` was written as `www\.example.com` already. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -500,7 +500,26 @@ export const MdastAutolinkLiteralExtension = defineExtension({ | |
| // literal, and gfmAutolinkLiteralFromMarkdown finds literals in the | ||
| // decoded text, where a reference is its character. | ||
| micromarkExtensions: [referenceAgnostic(gfmAutolinkLiteral)], | ||
| toMarkdownExtensions: [/* @__PURE__ */ gfmAutolinkLiteralToMarkdown()], | ||
| toMarkdownExtensions: [ | ||
| /* @__PURE__ */ gfmAutolinkLiteralToMarkdown(), | ||
| // Its rule escapes the `.` of `www.` only before an ASCII letter or | ||
| // digit, `_`, `-` or `.` as typed, but micromark starts a literal | ||
| // before anything else the export writes there too, such as a | ||
| // character reference, an escape or the marker of a format, and | ||
| // reads it as part of the link. This rule has no `after`, because | ||
| // mdast-util-to-markdown skips a rule that has an `after` where a | ||
| // rule with no condition escapes the next character, as one does `*`. | ||
| { | ||
| unsafe: [ | ||
| { | ||
| before: '[Ww]{3}', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional, non-blocking:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Joined adjacent text siblings before serializing in f4e59ed, so the rule sees the whole |
||
| character: '.', | ||
| inConstruct: 'phrasing', | ||
| notInConstruct: ['autolink', 'link', 'image', 'label'], | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| }), | ||
| ], | ||
| name: '@lexical/mdast/AutolinkLiteral', | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.