pandoc

How to use a colon (:) in the title of a Pandoc document


In text.md file, the following is the title:

---
title: Heading1: Heading2
---

Due to the colon (:), executing the following command yields an error message:

pandoc text.md -f markdown --filter=mermaid-filter --filter=pandoc-eqnos -o text.pdf

The error message:

YAML parse exception at line 1, column 18: mapping values are not allowed in this context

The following is the environment:

pandoc 2.18
Compiled with pandoc-types 1.22.2, texmath 0.12.5.1, skylighting 0.12.3.1,
citeproc 0.7, ipynb 0.2, hslua 2.2.1
Scripting engine: Lua 5.4

Solution

  • See documentation. Relevant quote:

    Note that YAML escaping rules must be followed. Thus, for example, if a title contains a colon, it must be quoted, and if it contains a backslash escape, then it must be ensured that it is not treated as a YAML escape sequence.

    So for your case:

    ---
    title: 'Heading1: Heading2'
    ---