Closed bdkjones closed 9 years ago
There is already a metadata key named Transclude Base
which allows you to define a central path for such snippets. This key/path can be set in every document, so you could even create different folders for different document types (say letters, articles etc.).
Doesn't the transclude base
apply to every import, though? So even if the content.md
file existed right next to the base file in my example above, if I specify a transclude base
metadata value, will that "override" the first search path, which would normally be the relative path specified in the {{..}}
statement?
In other words, I don't want to start every search for a transcluded file from a different base path; I merely want to provide some fallback paths to check in the event a transcluded file is not found with just the relative path specified in the {{...}}
statement.
Yes, Transclude Base
applies to every import. As far as I know, you can't mix Transclude Base
and relative transclusion paths in the same document.
Please also note that you can't use {{~/joe/Documents/document.md}}
since MMD doesn't resolve ~
to /Users/joe
. You also can't use absolute paths like {{/Users/joe/Documents/document.md}}
, at least on my machine this does not work.
A lack of support for the ~ is not surprising, but I would have expected root-relative paths to resolve. (Hadn't actually tried it).
Perhaps this is a cross-platform complexity?
I've added support for absolute paths, but need a few more tweaks before releasing it.
I don't plan on supporting ~
.
I don't plan on supporting multiple "search directories" for transcluded files.
Absolute paths supported in recent commit.
Suppose I have a Markdown file that includes another, like this:
Now suppose that
content.md
does not exist in the same directory as this base file. What I'd like is a way to pass a set of paths to the CLI that informs the compiler that it should check each of those paths, in order, to attempt to findcontent.md
, when the original lookup attempt fails to find a file.Use Case
This makes it easy to re-use a Markdown snippet across many projects without keeping multiple copies of the snippet on disk. For example, suppose you have a "legalese" footer that you have to add to the bottom of each document you create. It would be great to have "legalese.md" in
~/Documents
and then simply use that file from anywhere by telling the MMD compiler to check~/Documents
when it has trouble resolving a transcluded path.Right now, you've either got to copy "legalese.md" into multiple folders next to each base file that transcludes it, or you've got to worry about writing fragile relative paths between the base file and the location of the shared "legalese.md" file (and updating those paths when you move files around).
Thanks!