Brett on 10 Oct, 2018 08:38 PM
If the paths to the images within the included files are relative paths,
they have to be relative to the main index file. Thus, if your file were
in "base" and your documents were in "base/files" and your images were
The image reference in files/files1.md (when included in index.md) would
need to be !(images/image1.jpg), even though if that file were viewed
directly, it would need to be !(../images/image1.jpg).
When Marked merges all of the files, it's not rendering the Markdown
until the merge is complete, for fairly obvious reasons (footnotes, for
example, defined in a separate file, would never render, table of
contents can't be generated until the document structure is complete,
etc.). Thus, once it's all combined, the index file's location is the
only reference point on disk for any relative image referenced in an
included file. Everything acts as if it was referenced from the location
of the index file. Does that make sense?
Also, mmd_merge is the only format that allows a structure/hierarchy to
be specified, thus the only one that modifies header levels of included
Brett on 10 Oct, 2018 08:50 PM
It might be easiest if you drew out (or zipped up a sample) the
structure, showing where the index file is in relation to the included
files and the images.
Based on that example, and assuming the index is in the same folder as
the "files" folder, the images would need to be referenced as
!(files/images/image1.jpg), whereas I'm assuming they currently just
Is there a specific reason you need to keep the Marked index document
outside of the folder with the files? Putting it in the same folder
would alleviate the need to have different paths, and as it is, it
sounds like altering your paths would break images in whatever other app
you're using with the same files.
I've attached a screenshot of what a sample project folder would look like.
I'd like to keep the Marked index file outside of the folder with all of the component documents for ease of use with the other tool that uses my markdown files. Right now, it's just one file but I imagine use cases where I'll have different index files including different subsets of the component files
currently referencing the images as !(images/image1.jpg) yes
Brett on 16 Oct, 2018 08:28 PM
I don't know why I didn't think to mention this, but you could try setting an "include base" metadata key to specify the base directory your other files are in.
Add this at the top of the document (modified for your actual path names)
Include Base: /Users/youruser/Documents/project/files
That should alter the base directory that Marked is looking for included files from, so when an image is referenced with "images/image1.jpg", it should look for it in "files/images/image1.jpg". I can't guarantee this works, it's a bit fickle and I haven't tested in this case, but worth a shot if you're still figuring this out.