mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-31 18:07:00 +02:00
fix(v2): fix encoding of markdown image/file inline file-loaders (#4736)
* try to reproduce windows edge case due to file encoding * mdx loader => required file paths should be escaped * revert bad change * try to fix posix path issues * try to fix posix path issues * attempt to fix the file-loader edge cases with non-ascii chars * Add more example image edge-cases
This commit is contained in:
parent
39105f03d4
commit
a79c70c954
12 changed files with 148 additions and 40 deletions
|
@ -11,7 +11,11 @@ const url = require('url');
|
|||
const fs = require('fs-extra');
|
||||
const escapeHtml = require('escape-html');
|
||||
const {getFileLoaderUtils} = require('@docusaurus/core/lib/webpack/utils');
|
||||
const {posixPath, toMessageRelativeFilePath} = require('@docusaurus/utils');
|
||||
const {
|
||||
posixPath,
|
||||
escapePath,
|
||||
toMessageRelativeFilePath,
|
||||
} = require('@docusaurus/utils');
|
||||
|
||||
const {
|
||||
loaders: {inlineMarkdownImageFileLoader},
|
||||
|
@ -22,7 +26,9 @@ const createJSX = (node, pathUrl) => {
|
|||
jsxNode.type = 'jsx';
|
||||
jsxNode.value = `<img ${node.alt ? `alt={"${escapeHtml(node.alt)}"} ` : ''}${
|
||||
node.url
|
||||
? `src={require("${inlineMarkdownImageFileLoader}${pathUrl}").default}`
|
||||
? `src={require("${inlineMarkdownImageFileLoader}${escapePath(
|
||||
pathUrl,
|
||||
)}").default}`
|
||||
: ''
|
||||
}${node.title ? ` title="${escapeHtml(node.title)}"` : ''} />`;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue