including other quarkdown files - iamgio/quarkdown GitHub Wiki
The .include {file}
function makes it possible to load and evaluate an external Quarkdown source file.
Its parameter accepts a string which represents the path to the target file, which may be relative to the location of the main source file, or absolute.
Although its implementation is not "macro-like", its result is quite similar to it: you can think of it as if the content of the target file was inserted in place of the function call.
The result of the call is the visible output produced by the compilation of the file:
a.qmd
### Hello Quarkdown This is external content.
main.qmd
.include {a.qmd}
Output:
This is external content.
Any information about the context and environment is automatically inherited and can be modified by the included file.
This means declared functions and variables are imported as well in the main file.
Tip
You can take this to your advantage to make awesome libraries!
a.qmd
.function {greet} name: Hello, **.name**!
main.qmd
.include {a.qmd} .greet {John}
Output:
Hello, John!
Caution
Circular dependency results in an error.
A common use case would be putting all the setup function calls in a separate file (see the Setting up section of this wiki to see all).
setup.qmd
.docname {My document} .docauthor {iamgio} .doctype {slides} .doclang {English} .theme {darko} layout:{minimal} .footer ...
main.qmd
.include {setup.qmd} # My cool document ...