-
-
Notifications
You must be signed in to change notification settings - Fork 20
Including other Quarkdown files
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.
To include external libraries, please refer to Importing external libraries.
You can think of it as if the content of the target file was inserted in place of the function call.
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 files.
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 clean approach with using typesetting systems would be having a main file which gathers all the different subfiles together.
For this purpose, the .includeall
function, which takes an Iterable of paths, comes particularly handy as a shorthand for repeated .include
calls.
The following snippet is taken from Mock's main.qmd
file:
.includeall
- setup.qmd
- headings.qmd
- paragraphs.qmd
- lists.qmd
- images.qmd
- tables.qmd
- code.qmd
- textformatting.qmd
- colorpreview.qmd
- quotes.qmd
- boxes.qmd
- math.qmd
- mermaid.qmd
- collapsibles.qmd
- errors.qmd
- separators.qmd
- alignment.qmd
- stacks.qmd
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 ...
- Figures
- Image size
- TeX formulas
- Table caption
- Decorative headings
- Alerts (quote types)
- Quotation source
- Page breaks
- Text symbols (text replacement)
- Syntax of a function call
- Declaring functions
- Dynamic typing
- Including other Quarkdown files
- Importing external libraries
- Localization
- Document metadata
- Theme
- Page format
- Page margin content
- Page counter
- Automatic page break
- Numbering
- Table of contents
- Stacks (row, column, grid)
- Container
- Align
- Float
- Figure
- Clip
- Box
- Collapsible
- Whitespace
- Variables
- Optionality
- Math
- Conditional statements
- Loops
- Let
- Destructuring
- String manipulation
- Table manipulation: sorting, computing, and more
- Generators
- String
- Number
- Markdown content
- Boolean
- None
- Enumeration entry
- Iterable
- Dictionary
- Range
- Lambda
- Size(s)
- Color
- Dynamic
- Paper: abstract, definitions, theorems, and more