Markbind: Src tag: unintuitive as resources are relative to included folder

Created on 19 Jan 2019  路  6Comments  路  Source: MarkBind/markbind

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.

a-AuthorUsability c.Enhancement p.Medium

Most helpful comment

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.

All 6 comments

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.

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.

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

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 馃憤

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

Added index.md to issue description.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

damithc picture damithc  路  5Comments

jamos-tay picture jamos-tay  路  4Comments

Xenonym picture Xenonym  路  3Comments

le0tan picture le0tan  路  7Comments

yamgent picture yamgent  路  5Comments