vuepress / core

Vue-Powered Static Site Generator
https://vuepress.vuejs.org
MIT License
2.29k stars 926 forks source link

[Feature request] Optionally allow invalid links in Markdown #1465

Closed lifehackerhansol closed 7 months ago

lifehackerhansol commented 8 months ago

Clear and concise description of the problem

Crowdin, a widely-known translation platform, has a certain configuration called "In-Context" translating. This essentially embeds a small JavaScript and a set of template strings that consist of string identifiers for Crowdin. You can read more about Crowdin's in-context translation setup here: https://developer.crowdin.com/in-context-localization/

However, when doing it this way, Crowdin generates links like this:

1. crwdns6233:0crwdne6233:0![crwdns6231:0crwdne6231:0](crwdns6229:0crwdne6229:0)

and this breaks compilation:

[vite:load-fallback] Could not load C:/Users/lifehackerhansol/Documents/Git/dsi.cfw.guide/docs/translate/crwdns6229:0crwdne6229:0 (imported by docs/.vuepress/.temp/pages/translate/file-extensions-(windows).html.vue): ENOENT: no such file or directory, open 'C:\Users\lifehackerhansol\Documents\Git\dsi.cfw.guide\docs\translate\crwdns6229:0crwdne6229:0'

You can view an example of a project using this configuration here: https://github.com/cfw-guide/dsi.cfw.guide, where we temporarily worked around it with a hack.

Suggested solution

If possible, it would be nice to disable this open check, ideally for specific files.

I don't know at all if this is possible, as I don't really know enough JS to look around for ideas.

Alternative

No response

Additional context

No response

lifehackerhansol commented 8 months ago

I also don't really know if it's something that should be done here or done in Vite itself. I assumed the former, as VitePress did it there as well.

Mister-Hope commented 8 months ago

There is something you should know:

images (and other assets like video and font) setting with local file path needed to be resolved and handled while packing.

In another word, these must be valid:

These can be invalid as they are kept as is and not being resolved:

So in your case, you definitely could write image link with protocol or starting with /, the others like a.jpg will require a local a.jpg.

Mister-Hope commented 8 months ago

I also don't really know if it's something that should be done here or done in Vite itself. I assumed the former, as VitePress did it there as well.

cc @meteorlxy I think we can support this to avoid broken relative image link stops the build process.

meteorlxy commented 8 months ago

Ummm... IMO the ignoreDeadLinks of VitePress is not doing the same thing. It's used for skipping VitePress' built-in dead links checking.

github-actions[bot] commented 7 months ago

This issue is marked as stale because it has not had recent activity. Issues marked with stale will be closed if they have no activity within 7 days.