-
-
Notifications
You must be signed in to change notification settings - Fork 6
Configuration
Apex offers a flexible configuration system so you can define defaults once and reuse them across many documents, while still allowing per-document and per-invocation overrides.
This page covers:
- Where configuration comes from
- The global
config.ymlfile (XDG-aware) - Using
--meta-filewith reusable config files - Per-document metadata (front matter)
- Precedence rules between these sources
- Available configuration keys and their possible values
Apex can read configuration from three main places:
-
Global configuration file
-
$XDG_CONFIG_HOME/apex/config.ymlwhenXDG_CONFIG_HOMEis set -
~/.config/apex/config.ymlwhenXDG_CONFIG_HOMEis not set - Loaded automatically when present if you do not pass
--meta-file
-
-
External metadata files
- Any file you pass explicitly with
--meta-file FILE - Shared configuration for multiple documents
- Any file you pass explicitly with
-
Per-document metadata
- YAML, MultiMarkdown, or Pandoc-style metadata at the top of the document
- Used for settings that are specific to a single document
On top of all of these, you can always pass command-line flags such as --mode, --pretty, --no-tables, etc.
When you run apex without an explicit --meta-file, Apex will check for a global configuration file named config.yml in an XDG-aware location:
- If
$XDG_CONFIG_HOMEis set:$XDG_CONFIG_HOME/apex/config.yml
- Otherwise:
~/.config/apex/config.yml
If the file exists, Apex loads it as if you had passed it via --meta-file, and merges its metadata with the document and any --meta command-line metadata using the normal precedence rules (see below).
This makes config.yml ideal for defining project‑agnostic defaults, such as:
- Default
mode(e.g.unified,gfm,mmd) - Default
languageandquoteslanguage - Common feature flags (
pretty,standalone,indices,wikilinks, etc.) - Default bibliography style for your writing workflow
---
# Default processor mode and output style
mode: unified
standalone: true
pretty: true
# Locale and quotation style
language: en
quoteslanguage: english
# Common feature flags
autolink: true
includes: true
relaxed-tables: true
sup-sub: true
# Index and bibliography defaults
indices: true
group-index-by-letter: true
bibliography: references.bib
csl: apa.csl
---With this configuration in place, a simple command like:
apex document.mdwill automatically use your global defaults. You can then override any of them with per-document metadata or CLI flags when needed.
For project-specific or task-specific configurations, use --meta-file to point to a reusable metadata file:
apex document.md --meta-file project-defaults.ymlThese files use the same metadata keys as config.yml and document front matter.
---
mode: unified
standalone: true
pretty: true
# Project-specific bibliography
bibliography: project-refs.bib
csl: chicago-note-bibliography.csl
# Enable wiki links and relaxed tables for this project
wikilinks: true
relaxed-tables: true
---You can reuse the same project-defaults.yml for many documents:
apex chapter1.md --meta-file project-defaults.yml
apex chapter2.md --meta-file project-defaults.yml
apex appendix.md --meta-file project-defaults.ymlIf a global config.yml is also present, the explicit --meta-file still participates as the "file metadata" layer; precedence is determined by the rules below.
Each document can define its own metadata in YAML, MultiMarkdown, or Pandoc formats. Apex extracts this metadata before processing, merges it with any file/config metadata, and then applies it to options.
---
title: My Research Paper
author: Jane Doe
mode: unified
standalone: true
pretty: true
indices: false
wikilinks: true
bibliography: references.bib
language: en
quoteslanguage: english
---
# Introduction
...Title: My Research Paper
Author: Jane Doe
Mode: unified
Standalone: true
Pretty: true
Indices: false
WikiLinks: true
Bibliography: references.bib
Language: en
Quotes Language: english
# Introduction
...Apex normalizes keys (case-insensitive, ignores spaces and dashes), so Quotes Language, quoteslanguage, and quotes-language are treated equivalently.
When Apex builds the final configuration for a run, it merges all sources in this order:
-
File metadata (lowest precedence)
- Global
config.ymlif present and no explicit--meta-filewas given - Any metadata file provided via
--meta-file
- Global
-
Document metadata
- YAML/MultiMarkdown/Pandoc metadata inside the document
-
Command-line metadata
- Values passed via
--meta KEY=VALUE
- Values passed via
-
Command-line flags
- Flags like
--mode,--pretty,--no-tables, etc.
- Flags like
Later sources override earlier ones. In practice:
- A document can override defaults from
config.ymlor--meta-file -
--metavalues can override both document and file metadata - Explicit CLI flags (
--mode gfm,--no-tables, etc.) still behave as final overrides where applicable
Note: if mode is specified in metadata (file or document), Apex resets options to that mode's defaults before applying other metadata keys, so the mode behaves as if you had passed it on the command line first.
Configuration keys correspond closely to Apex command-line options. Most options can be controlled via metadata in config.yml, --meta-file files, or per-document metadata.
Boolean keys accept any of the following values (case-insensitive):
-
true/false -
yes/no -
1/0
Supported boolean keys include:
-
indices– Enable index processing -
wikilinks– Enable wiki link syntax ([[Page]]) -
includes– Enable file inclusion -
relaxed-tables– Enable relaxed table parsing -
alpha-lists– Enable alphabetic list markers -
mixed-lists– Allow mixing list marker types at the same level -
sup-sub– Enable MultiMarkdown-style superscript/subscript -
autolink– Enable automatic URL/email linking -
transforms– Enable metadata transforms ([%key:transform]) -
unsafe– Allow raw HTML in output -
tables– Enable/disable table support -
footnotes– Enable/disable footnote support -
smart– Enable/disable smart typography -
math– Enable/disable math support -
ids– Enable/disable automatic header IDs -
header-anchors– Use<a>anchors instead of plainidattributes -
embed-images– Enable base64 image embedding -
link-citations– Link citations to bibliography entries -
show-tooltips– Add tooltips to citations -
suppress-bibliography– Suppress bibliography output -
suppress-index– Suppress index output while still creating markers -
group-index-by-letter– Group index entries alphabetically -
obfuscate-emails– Hex-encodemailto:links and visible email addresses -
pretty– Pretty-print HTML -
standalone– Generate a full HTML document (<html>,<head>,<body>) -
hardbreaks– Treat newlines as<br> -
plugins– Enable plugin processing for this document (see Plugins)
String keys take a free-form string value (sometimes with a constrained set of options):
-
mode- Values:
commonmark,gfm,mmd/multimarkdown,kramdown,unified
- Values:
-
id-format- Values:
gfm,mmd,kramdown
- Values:
-
title- Document title (used especially in standalone mode)
-
style/css- Stylesheet path for standalone documents
-
base-dir- Base directory used for resolving relative paths (images, includes, etc.)
-
bibliography- Path to a bibliography file (
.bib,.json,.yml,.yaml)
- Path to a bibliography file (
-
csl- Path to a CSL style file
-
language- BCP 47 or similar language tag (e.g.
en,en-US,fr); sets the HTMLlangattribute
- BCP 47 or similar language tag (e.g.
-
quoteslanguage/Quotes Language- Human-readable language name used for quote styling (e.g.
english,french,german)
- Human-readable language name used for quote styling (e.g.
You can also use arbitrary keys for your own templates and transforms; Apex simply passes them through to the metadata system so they can be referenced via [%key] and [%key:transform].
A typical setup might look like this:
-
Global defaults in
config.ymlfor your overall writing style and locale. -
Project config via
--meta-file project.ymlfor bibliography and project-specific settings. - Per-document metadata for title, author, and any exceptions to the defaults.
- Occasional CLI overrides for ad-hoc one-off changes (e.g.
--mode gfmfor a specific run).
Because all three configuration layers use the same metadata keys, you can gradually refine behavior without repeating yourself:
- Put long‑lived, cross‑project settings in
config.yml - Put project‑scoped settings in
--meta-fileconfigs - Put document‑specific settings in front matter
For more examples of metadata usage and transforms, see Metadata Options and Metadata Transforms.
Copyright 2025 Brett Terpstra, All Rights Reserved | MIT License
- Getting Started - Your first steps with Apex
- Installation - How to build and install Apex
- Usage - Basic usage examples
- Syntax - Complete syntax reference for unified mode
- Callouts - All supported callout formats and flag requirements
- Tables - Complete table syntax reference including rowspan, colspan, alignment, and captions
- Inline Attribute Lists - IALs and ALDs guide with examples
- Modes - Understanding processor modes
-
Quarto Mode - Pandoc/Quarto markdown (
--mode quarto) - Command Line Options - All CLI flags explained
-
Rendering Markdown in the Terminal - Terminal output formats (
-t terminal,-t terminal256),--width,--theme, and theming -
Generating Man Pages - Generate man pages from Markdown using
apex -t man -
Multi-file Documents - Combining multiple files with
--combine,--mmd-merge, and includes - Citations - Citations and bibliography guide
- Indices - Index generation with mmark and TextIndex syntax
-
Metadata Transforms - Transform metadata values with
[%key:transform] - Integrating with Pandoc - Use Apex with Pandoc for DOCX, PDF, and more
- Using Apex with Jekyll - Use the apex-ruby gem as Jekyll’s Markdown converter (untested; feedback welcome)
- Header IDs - How header IDs are generated
- C API - Programmatic API documentation
- Writing Tests - How to add tests for new features
- Xcode Integration - Using Apex in Xcode projects
- Examples - Practical usage examples
- Plugins - Plugin system, examples, and recipes
- Filters - AST filters (Pandoc-style JSON), examples, and usage
- Troubleshooting - Common issues and solutions
- Credits - Acknowledgments and links to related projects