Marked Help

• Full Index

# Multi-file Documents

You can include external files in a single preview document by using the syntax <<[path/file] at the beginning of a line. The line should have blank lines above and below it, and the path is assumed to be relative to the main document unless it begins with a slash (/) or a tilde (~). Slash (root directory) and tilde (home directory) may be used to define absolute paths to files. No path is needed if the external files are in the same folder as the main document, just put the filename (case sensitive and including extension) in the square brackets.

Using this feature you can build large documents/books using multiple files (e.g. a file for each chapter) and then specify the document order in a single index file. It doesn’t matter how any of the files are named or how the folders are organized; the file you open in Marked will be considered the index and the files listed inside it will be included. An example of an index file for a three-part document:

Folder structure:

Index.md:

# Document title

## Section 1

<<[sections/section1.md]

## Section 2

<<[sections/section2.md]

## Section 3

<<[sections/section3.md]


Opening Index.md in Marked will display its contents with all three included files expanded inside. All included files will be watched for changes. Unlike the open document in Marked, included file tracking depends on Spotlight to obtain updates and must exist in a Spotlight-indexed folder on your disk.

You can also include code snippets and raw html or text using variations of this syntax.

Note: the more files included in a document, the slower the overall compile time of the preview will be. Marked tries to optimize and cache the process, but expect some rendering delays as your document size increases.

## Book Formats

Marked also supports index files in formats like Leanpub and mmd_merge (MultiMarkdown). These require that the first line be “frontmatter:” (Leanpub format) or “#merge” (special Marked trigger for mmd_merge, treated as a comment and ignored by other processors). Included files will be watched for changes and the result is a complete preview of your compiled document, just like the “Index.md” example above.