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

Src tag: unintuitive as resources are relative to included folder #598

Closed
sijie123 opened this issue Jan 19, 2019 · 6 comments · Fixed by #677
Closed

Src tag: unintuitive as resources are relative to included folder #598

sijie123 opened this issue Jan 19, 2019 · 6 comments · Fixed by #677

Comments

@sijie123
Copy link
Contributor

sijie123 commented Jan 19, 2019

Tell us about your environment

  • MarkBind Version: v1.16.1

What did you do? Please include the actual source code causing the issue.

Folder structure:

root/
- index.md
- a/
- - img.png
- - subsite.md

index.md

...
<include src="a/subsite.md" />

subsite.md

...
<img src="img.png" />

What did you expect to happen?
The subsite.md/html works, because the references are correct.
I would also expect any site reusing the subsite to work too. In this case, index.md should work and display img.png properly.

What actually happened? Please include the actual, raw output.
However, the image link is broken when viewing index.md/html. Upon inspection, the img src in index.html points to img.png, suggesting that the content of subsite.md is just copied into index.md.
To get the image to work on both sites, the code has to be changed to <img src='/a/img.png' />. However, this is tedious and unintuitive for authors to write.

Possible solution
In addition to the pre-process step of include, additionally pre-process the src tags too, replacing all relative URLs with their absolute path equivalent. For example, we could use {{baseUrl}}/a/img.png in the example above.

  • However, we need to be able to detect relative URLs vs absolute one, as well as handle additional edge cases like "http(s)://..." or "#".

Extension
This issue is also applicable to other media elements such as videos, downloadable files, css and hrefs.

@acjh
Copy link
Contributor

acjh commented Jan 24, 2019

Things to check/handle:

  • relative links that begin with ./, ../, ../../ etc. work correctly.
  • relative links in Boilerplate files should be relative to "missing" file, not boilerplates directory.

@damithc
Copy link
Contributor

damithc commented Feb 3, 2019

I realized that the current behavior makes MarkBind incompatible with Markdown, and upgrading a Markdown site to MarkBind will break the intra-site links within the site. :-(
I think we need to fix this before V2.

@acjh
Copy link
Contributor

acjh commented Feb 3, 2019

I don't think it breaks regular Markdown sites, as those can't <include> files elsewhere.

@acjh acjh changed the title Src tag: unintuitive as resources are relative to root folder Src tag: unintuitive as resources are relative to includer folder Feb 3, 2019
@damithc
Copy link
Contributor

damithc commented Feb 3, 2019

I don't think it breaks regular Markdown sites, as those can't <include> files elsewhere.

Right, I forgot that this affects included contents only 👍

@acjh
Copy link
Contributor

acjh commented Feb 3, 2019

@sijie123 Please help to add index.md contents to issue description.

@yamgent yamgent changed the title Src tag: unintuitive as resources are relative to includer folder Src tag: unintuitive as resources are relative to included folder Feb 3, 2019
@sijie123
Copy link
Contributor Author

sijie123 commented Feb 4, 2019

Added index.md to issue description.

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

Successfully merging a pull request may close this issue.

3 participants