Skip to content
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

[v2] Couldn't link to static assets with Chinese characters under sub-dir #3471

Closed
niheaven opened this issue Sep 22, 2020 · 7 comments
Closed
Labels
bug An error in the Docusaurus core causing instability or issues with its execution status: needs more information There is not enough information to take action on the issue.

Comments

@niheaven
Copy link

🐛 Bug Report

When linking to static assets (pdf or xlsx, etc.) directly from markdown files, and if the file is under some co-locate subdir and has Chinese characters in its path name (filename or dirname), then the parsing engine will give some error as following:

./docs/doc2.md
Module not found: Can't resolve './0202测试.pdf' in 'xxx\docusaurus\docs'./docs/doc2.md
Module not found: Can't resolve './test测试.pdf' in 'xxx\docusaurus\docs'./docs/doc2.md
Module not found: Can't resolve './测试 est.pdf' in 'xxx\docusaurus\docs'

Have you read the Contributing Guidelines on issues?

YES

To Reproduce

  1. Create some dummy files and dirs under docs, e.g., 测试/test.pdf, test/测试.pdf, 0202/测试.pdf
  2. Link to these files in md file under docs, e.g., doc2.md, using markdown's syntax (Link to [subdir with Chinese path name 1](test/测试.pdf)) (Webpack's works well <a ... require('./0202/测试.pdf').default ... /a>)
  3. Save doc2.md

Expected behavior

No error, move these files to assests and create clickable links

Actual Behavior

× Client
  Compiled with some errors in 83.04ms



./docs/doc2.md
Module not found: Can't resolve './0202测试.pdf' in 'xxx\docusaurus\docs'./docs/doc2.md
Module not found: Can't resolve './test测试.pdf' in 'xxx\docusaurus\docs'./docs/doc2.md
Module not found: Can't resolve './测试 est.pdf' in 'xxx\docusaurus\docs'

Oh, line breaks got wrong, too...

Your Environment

  • Docusaurus version used: 2.0.0-alpha.64
  • Environment name and version: Edge 85.0.564.51, Node.js 12.18.4
  • Operating system and version: Windows 10 19042.487 64bit

Reproducible Demo

(Paste the link to an example repo, including a siteConfig.js, and exact instructions to reproduce the issue.)

Just add some Chinese named files and dirs...

@niheaven niheaven added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Sep 22, 2020
@slorber
Copy link
Collaborator

slorber commented Sep 29, 2020

Hi,

I'm sorry but I'm unable to reproduce this issue.

image

image

image

I would need a full repro to be able to debug this and be sure it's not an error on your side.

@slorber slorber added need more infos and removed status: needs triage This issue has not been triaged by maintainers labels Sep 29, 2020
@slorber slorber added status: needs more information There is not enough information to take action on the issue. and removed need more infos labels Oct 8, 2020
@slorber
Copy link
Collaborator

slorber commented Oct 8, 2020

no answer so closing

@slorber slorber closed this as completed Oct 8, 2020
@niheaven
Copy link
Author

niheaven commented Oct 9, 2020

Sorry, on vacation...

Please check https://github.com/niheaven/docusaurus-debug, and output on my machine likes:

image

init commit runs well.

@slorber slorber reopened this Oct 9, 2020
@slorber
Copy link
Collaborator

slorber commented Oct 9, 2020

Thanks, let's reopen.

The repro looks valid to me and docs/doc2.md should be able to link to these assets.

I don't have windows to test the repro, unfortunately, but people have reported that using other shells (like PowerShell) could solve problem. Can you try some other Windows shell if possible?

@niheaven
Copy link
Author

niheaven commented Oct 9, 2020

What I use is PowerShell 7, and I also tried PowerShell 5.1, CMD and nu shell. Unfortunately, the same error...

npm run start cannot work, too.

It seems like parsing engine treat ./assets/测试.pdf as ./assets\测试.pdf in Windows and the backslash is used as an escape character.

Double or quadruple backslash can't work, too...

@hotlong
Copy link

hotlong commented Jan 5, 2021

The same error.

Failed to compile
../docs/help/deploy/deploy_ubuntu.md
SyntaxError: unknown: Bad character escape sequence (118:192)

  116 | <p parentName="blockquote">{`只需执行一次`}</p>
  117 | </blockquote>
> 118 | <p><img alt={"暂存修改"} src={require("!url-loader?limit=10000&name=assets/images/[name]-[hash].[ext]&fallback=file-loader!C:\Users\steedos\Documents\GitHub\steedos-website\website\static\assets\ubuntu\git暂存修改.png").default}  /></p>
      |                                                                                                                                                                                                 ^
  119 | <p>{`其次写说明并提交更改:`}</p>
  120 | <p><img alt={"提交更改"} src={require("!url-loader?limit=10000&name=assets/images/[name]-[hash].[ext]&fallback=file-loader!C:\Users\steedos\Documents\GitHub\steedos-website\website\static\assets\ubuntu\git提交更改.png").default}  /></p>
  121 | <p>{`如果没有 git 客户端可选择取消打开 git 客户端,并在 vscode 中登陆 git 账号:`}</p>

@slorber
Copy link
Collaborator

slorber commented May 6, 2021

Should be fixed by #4736

Please let me know if you still have an issue

@slorber slorber closed this as completed May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution status: needs more information There is not enough information to take action on the issue.
Projects
None yet
Development

No branches or pull requests

3 participants