mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-07 21:32:38 +02:00
fix(utils): better handling of code blocks in link replacement (#9046)
This commit is contained in:
parent
dcce8ff3cd
commit
76f920359b
3 changed files with 73 additions and 9 deletions
|
@ -47,6 +47,22 @@ exports[`replaceMarkdownLinks handles stray spaces 1`] = `
|
|||
}
|
||||
`;
|
||||
|
||||
exports[`replaceMarkdownLinks handles unpaired fences 1`] = `
|
||||
{
|
||||
"brokenMarkdownLinks": [],
|
||||
"newContent": "
|
||||
\`\`\`foo
|
||||
hello
|
||||
|
||||
\`\`\`foo
|
||||
hello
|
||||
\`\`\`
|
||||
|
||||
A [link](/docs/file)
|
||||
",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`replaceMarkdownLinks ignores links in HTML comments 1`] = `
|
||||
{
|
||||
"brokenMarkdownLinks": [
|
||||
|
|
|
@ -371,6 +371,32 @@ The following operations are defined for [URI]s:
|
|||
[URL](./file.md?foo=bar#baz)
|
||||
[URL](./file.md#a)
|
||||
[URL](./file.md?c)
|
||||
`,
|
||||
}),
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('handles unpaired fences', () => {
|
||||
expect(
|
||||
replaceMarkdownLinks({
|
||||
siteDir: '.',
|
||||
filePath: 'docs/file.md',
|
||||
contentPaths: {
|
||||
contentPath: 'docs',
|
||||
contentPathLocalized: 'i18n/docs-localized',
|
||||
},
|
||||
sourceToPermalink: {
|
||||
'@site/docs/file.md': '/docs/file',
|
||||
},
|
||||
fileString: `
|
||||
\`\`\`foo
|
||||
hello
|
||||
|
||||
\`\`\`foo
|
||||
hello
|
||||
\`\`\`
|
||||
|
||||
A [link](./file.md)
|
||||
`,
|
||||
}),
|
||||
).toMatchSnapshot();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue