relative path in the transclusion files

22 views
Skip to first unread message

Michael Chen

unread,
Apr 30, 2016, 1:57:29 PM4/30/16
to MultiMarkdown Discussion List
I have folders chapter1, ...., chapter14; and within each fold chapterN, there is a markdown file chapterN.md and a subfolder image. The chapterN.md contains ![bla](image/bla.png).

I listed all markdown files in my index file as:

{{chapter1/chapter1.md}}
{{chapter2/chapter2.md}}
.
.
.
etc.

After the file transclusion, the images are still referenced as "image/bla.png", which should be "chapter1/image/bla.png". Shall we fix this?



Tore Haug-Warberg

unread,
Nov 23, 2016, 10:36:29 AM11/23/16
to MultiMarkdown Discussion List
I have the same needs myself. As far as I can understand {{<file>}} opens <file> recursively, thus incrementing the relative path at each level of transclusion, whereas ![](<file> "") opens <file> *after* the document has been *linearized*. In my opinion this makes MMD less valuable as a tool for  parsing hierarchical document structures. I would say it is within the 80 : 80 philosophy of MMD.

Fletcher T. Penney

unread,
Nov 23, 2016, 10:56:33 AM11/23/16
to Tore Haug-Warberg, MultiMarkdown Discussion List
This is more a matter of choosing a thoughtful structure for your
project before using transclusion than a problem for MMD to solve.

MMD does not "police" URLs to ensure accuracy. It uses what you tell it
to use, on the assumption you know what you are doing.

The contents of a MMD document are just text.... They have no
"location" per se. This is why you can pipe text directly to the
multimarkdown command (e.g. `cat foo.txt | multimarkdown`).

Transclusion is handled slightly differently, because it has to be. By
definition, transclusion requires that MMD "knows" where a file is, and
where transcluded files are.

So an image URL, e.g. `<image/bla.png>`, is left alone. MMD has know
way of knowing your intent when using that URL. It may be that the text
will be processed and sent to an entirely different computer/server for
hosting on a web site.


In your use case, you want to develop a thoughtful structure that works
whether you are transcluding or not. For example, all images could go
in a single directory (e.g. `images`), and there is only one level of
transclusion nesting. Images can be referenced by
`../images/image-1.png` from any of the chapters. The main file would
also be in a level 1 directory, so that it can also reference `../images`.

project
|
- images
|
- chapter1
|
_ chapter2
|
- main


Fletcher


On 11/23/16 10:33 AM, Tore Haug-Warberg wrote:
> I have the same needs myself. As far as I can understand {{<file>}}
> opens <file> recursively, thus incrementing the relative path at each
> level of transclusion, whereas ![](<file> "") opens <file> *after* the
> document has been *linearized*. In my opinion this makes MMD less
> valuable as a tool for parsing hierarchical document structures. I
> would say it is within the 80 : 80 philosophy of MMD.
>
>
> On Saturday, April 30, 2016 at 7:57:29 PM UTC+2, Michael Chen wrote:
>
> I have folders chapter1, ...., chapter14; and within each fold
> chapterN, there is a markdown file chapterN.md and a subfolder
> image. The chapterN.md contains ![bla](image/bla.png).
>
> I listed all markdown files in my index file as:
>
> {{chapter1/chapter1.md <http://chapter1.md>}}
> {{chapter2/chapter2.md <http://chapter2.md>}}
> .
> .
> .
> etc.
>
> After the file transclusion, the images are still referenced as
> "image/bla.png", which should be "chapter1/image/bla.png". Shall we
> fix this?
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "MultiMarkdown Discussion List" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to multimarkdow...@googlegroups.com
> <mailto:multimarkdow...@googlegroups.com>.
> To post to this group, send email to multim...@googlegroups.com
> <mailto:multim...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/multimarkdown.
> For more options, visit https://groups.google.com/d/optout.

--
Fletcher T. Penney
fletche...@gmail.com

Tore Haug-Warberg

unread,
Nov 23, 2016, 11:30:47 AM11/23/16
to MultiMarkdown Discussion List
For one reason or the other I did not spot Fletcher's reply to Michael's post before I had posted my own. Sorry! The fact that MMD is a filter that should work also for pipes is important. I have to rethink the subject. You see: I do not like to flatten the directory structure (of pictures) because I am linearising the master document (MMD file) even though I see the technical argument of doing so...

Fletcher T. Penney

unread,
Nov 23, 2016, 11:37:07 AM11/23/16
to MultiMarkdown Discussion List
Same approach can still apply, use `../chapter1/images/image-1.png` --
this would be valid from any first level subdirectory.


F-

On 11/23/16 11:30 AM, Tore Haug-Warberg wrote:
> For one reason or the other I did not spot Fletcher's reply to Michael's
> post before I had posted my own. Sorry! The fact that MMD is a filter
> that should work also for pipes is important. I have to rethink the
> subject. You see: I do not like to flatten the directory structure (of
> pictures) because I am linearising the master document (MMD file) even
> though I see the technical argument of doing so...
>

Reply all
Reply to author
Forward
0 new messages