Skip to content

Directives

MDLeaf adds a handful of directives for pagination features. A directive is a single line:

::name
::name[label]
::name{attrs}
::name[label]{attrs}
DirectiveWhat it doesPage
::pagebreakStarts a new pagePage breaks
::tocTable of contents with page numbersTable of contents
::header[…], ::footer[…]Running header or footer from this page onHeaders and footers
::hide{…}Hides header and/or footer on one pageHiding headers
::pagenumber{…}Restarts or offsets the page numbersPage numbering
cover-page/document.md
::header[Annual report||2026]
::footer[|Page {page} of {pages}|]
# Annual Report 2026
Prepared for the board.
::pagebreak
::hide{header}
::toc{depth=2}
::pagebreak
::pagenumber{start=1}
## Summary
MDLeaf lays Markdown out on real pages. Paragraphs flow from page to page, and the page view shows exactly what the PDF will contain.
MDLeaf lays Markdown out on real pages. Paragraphs flow from page to page, and the page view shows exactly what the PDF will contain.
::pagebreak
## Results
MDLeaf lays Markdown out on real pages. Paragraphs flow from page to page, and the page view shows exactly what the PDF will contain.
MDLeaf lays Markdown out on real pages. Paragraphs flow from page to page, and the page view shows exactly what the PDF will contain.
A cover page without header and footer, a contents page, and numbering that restarts at 1 for the first chapter. {pages} counts the displayed numbers.
Download sample (.mdl)

Open it in MDLeaf with Library → Import .mdl. If MDLeaf is installed, you can also open the file directly.

directive = "::" name [ "[" label "]" ] [ "{" attrs "}" ] *WSP EOL
name = lowercase letter, then lowercase letters, digits or "-"
label = any text; write "\]" for "]" and "\|" for a literal "|"
attrs = zero or more attributes separated by spaces
attr = key "=" value / key ; a bare key is a flag
value = text without spaces, or "a quoted value" (\" for a quote)
  • At the start of a line (column 0), with nothing else on the line.
  • At the top level of the document: not inside a list, quote, table, code block or footnote.
  • A directive line may follow a paragraph directly; it always ends that paragraph.
  • To write the characters literally, escape them: \::pagebreak shows ::pagebreak.

The editor highlights directives in violet, their labels in a lighter violet and attributes in teal.

ProblemDiagnostic
A misspelt name such as ::pagebrake stays as textdirective-unknown (warning)
An indented directive, or one inside a list or quote, stays as textdirective-misplaced (warning)
An attribute the directive does not have is ignoreddirective-attr-unknown (warning)
An invalid value, such as ::toc{depth=9}, ignores the whole directivedirective-attr-invalid (error)

See all diagnostics.