Skip to content

Commit

Permalink
Fix serializer test and account for escaped quote in title
Browse files Browse the repository at this point in the history
  • Loading branch information
Rory Jennings committed Mar 20, 2023
1 parent e10a073 commit 1f2f807
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/lexical-markdown/src/MarkdownTransformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,10 @@ export const LINK: TextMatchTransformer = {
return linkContent;
}
},
importRegExp: /(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"([^"]+)"\s*)?)\))/,
regExp: /(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"([^"]+)"\s*)?)\))$/,
importRegExp:
/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,
regExp:
/(?:\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,
replace: (textNode, match) => {
const [, linkText, linkUrl, linkTitle] = match;
const linkNode = $createLinkNode(linkUrl, {title: linkTitle});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ describe('Markdown', () => {
html: '<p><a href="https://lexical.dev" title="Hello world"><span>Hello</span></a><span> world</span></p>',
md: '[Hello](https://lexical.dev "Hello world") world',
},
{
html: '<p><a href="https://lexical.dev" title="Title with \\&quot; escaped character"><span>Hello</span></a><span> world</span></p>',
md: '[Hello](https://lexical.dev "Title with \\" escaped character") world',
},
{
html: '<p><span>Hello </span><s><i><b><strong>world</strong></b></i></s><span>!</span></p>',
md: 'Hello ~~***world***~~!',
Expand Down
Loading

0 comments on commit 1f2f807

Please sign in to comment.