Process file includes relative to the file doing the include

jamie's Avatar


15 Jul, 2012 03:47 PM

I started a new project and decided to use a folder of Markdown documents with some folder hierarchy for sections and whatnot. Right now, it's pretty simple, but one thing I did notice was that all includes appear to be relative to the master document. I have something like this:

  • Project root
    • Project
    • Section 1
      • subsection1 *subsection2 *subsection3

What I would like to do is include in with <<[] but Marked only supports includes relative to the root file. One reason for this is the structure of my project means having a file with the same name in each section that I want to include in the section file, which then gets included in the main project file.

  1. Support Staff 1 Posted by Brett on 15 Jul, 2012 03:54 PM

    Brett's Avatar

    I'm afraid I don't understand the question. If you're talking about a directory structure, you can just use <<[subsection2/]. Due to the potential for infinite loops in recursive includes, there are some limitations, but that should work for you... am I missing something?

  2. 2 Posted by jamie on 16 Jul, 2012 01:11 PM

    jamie's Avatar

    Well, Tender managed to munge my Markdown; imagine that.

    If and are sibling files, I want to be able to include file4 in file3 without specifying the containing directory.


    My feeling is this should basically correspond to


    This is a tiny nit to be sure, but it was something I ran into quickly in trying to use Marked for the first time with a larger endeavor.

  3. Support Staff 3 Posted by Brett on 18 Jul, 2012 03:19 PM

    Brett's Avatar

    I'll look into this. I'm having trouble wrapping my head around any potential consequences right now, but I did make it recursive so I need to figure out the best way to handle base paths for nested includes. It makes sense that everything should be relative to the document containing the include, though. I'll play with it.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac