mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-22 05:27:00 +02:00
fix(v2): escape alt text in img tag (#3757)
This commit is contained in:
parent
3ad453932f
commit
311be6e71a
3 changed files with 5 additions and 1 deletions
|
@ -18,6 +18,8 @@ exports[`transformImage plugin transform md images to <img /> 1`] = `
|
||||||
|
|
||||||
<img alt={\\"img\\"} src={require(\\"!url-loader?limit=10000&name=assets/images/[name]-[hash].[ext]&fallback=file-loader!./img.png\\").default} title=\\"Title\\" /> <img alt={\\"img\\"} src={require(\\"!url-loader?limit=10000&name=assets/images/[name]-[hash].[ext]&fallback=file-loader!packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/fixtures/img.png\\").default} />
|
<img alt={\\"img\\"} src={require(\\"!url-loader?limit=10000&name=assets/images/[name]-[hash].[ext]&fallback=file-loader!./img.png\\").default} title=\\"Title\\" /> <img alt={\\"img\\"} src={require(\\"!url-loader?limit=10000&name=assets/images/[name]-[hash].[ext]&fallback=file-loader!packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/fixtures/img.png\\").default} />
|
||||||
|
|
||||||
|
<img alt={\\"img with "quotes"\\"} src={require(\\"!url-loader?limit=10000&name=assets/images/[name]-[hash].[ext]&fallback=file-loader!./img.png\\").default} title=\\"'Quoted' title\\" />
|
||||||
|
|
||||||
## Heading
|
## Heading
|
||||||
|
|
||||||
\`\`\`md
|
\`\`\`md
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
 
|
 
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Heading
|
## Heading
|
||||||
|
|
||||||
```md
|
```md
|
||||||
|
|
|
@ -19,7 +19,7 @@ const {
|
||||||
|
|
||||||
const createJSX = (node, pathUrl) => {
|
const createJSX = (node, pathUrl) => {
|
||||||
node.type = 'jsx';
|
node.type = 'jsx';
|
||||||
node.value = `<img ${node.alt ? `alt={"${node.alt}"} ` : ''}${
|
node.value = `<img ${node.alt ? `alt={"${escapeHtml(node.alt)}"} ` : ''}${
|
||||||
node.url
|
node.url
|
||||||
? `src={require("${inlineMarkdownImageFileLoader}${pathUrl}").default}`
|
? `src={require("${inlineMarkdownImageFileLoader}${pathUrl}").default}`
|
||||||
: ''
|
: ''
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue