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

Rewriting paths #13

Open
BrekiTomasson opened this issue Feb 19, 2020 · 4 comments
Open

Rewriting paths #13

BrekiTomasson opened this issue Feb 19, 2020 · 4 comments

Comments

@BrekiTomasson
Copy link

Assuming you're in /opt/doc/file.md and you include ./included/first.md, but that file has an inline image referencing ./img/logo.gif, the resulting Markdown would be looking for /opt/doc/img/logo.gif, while the image is actually at /opt/doc/included/img/logo.gif.

Would it be possible (via a config flag or similar) to get the plugin to scan included files and rewrite any paths discovered accordingly? Something like path.resolve(basePath, path.resolve(path.dirname(path.join(basePath, importPath)) should do the trick, assuming basePath is the path of the parent file and importPath is the path of the imported file.

@camelaissani
Copy link
Owner

Sorry for my very late answer.

I'm not sure this issue is related to this plugin. The image paths are not computed by the includes.
When you write "inline image referencing ./img/logo.gif", do you mean that in markdown ![logo](./img/logo.gif)?

@alexfornuto
Copy link

I'm trying to use this in a Vuepress site, and I've only been able to get one combination of actual image location and path in Markdown to work. I've tried:

  • adding the image to the include directory and referencing it (./img/image.png)
  • adding the image to the img directory of the vuepress root and calling it with a complete line (/docs/img/image.png)
  • adding the img to an img folder relative to the file calling the include, and referencing it as if the include was in the same path (../img/image.png).

Only the third option has worked for me so far. Unfortunately this model is antithetical to the idea of the include, because I'll need to make sure that image is available (even if only by symlink) in a corresponding ../img folder wherever I use the include file.

@emiyl
Copy link

emiyl commented Oct 22, 2021

I believe I'm having a similar issue - I'm trying to include a markdown file inside an included markdown file.

An example below:

# /docs/main.md

!!!include(./docs/include1.md)!!!
# /docs/include1.md

!!!include(./docs/include2.md)!!!
# /docs/include2.md

Content

Unfortunately, when including include2.md, it tries to load it from both main.md and include1.md, so that it tries to load /docs/include2.md and /docs/docs/include.md.

@justindesrosiers
Copy link

I am experiencing the same problem as @emiyl . Has anyone found a solution to including files that include other files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants