Pandoc
lastmod 2026-03-27created 2023-11-2227 edits
Pandoc is a free and open-source document converter, widely used as a writing tool especially by scholars, and as a foundation for publishing workflows. It was developed by John MacFarlane, a philosophy professor at the University of California, Berkeley.
Categories
Installation
If you want to use --pdf-engine=xelatex:
How to apply a PDF Engine
#!/usr/bin/env bash
ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" || exit; pwd)
INPUT="$ROOT_DIR/MANUAL.ko.md"
OUTPUT="$ROOT_DIR/MANUAL.ko.pdf"
if ! command -v pandoc &> /dev/null; then
echo "Not found pandoc command" 1>&2
echo "Please install the 'pandoc' package" 1>&2
exit 1
fi
if [[ ! -f "$INPUT" ]]; then
echo "Not found input file: '$INPUT'" 1>&2
exit 1
fi
if ! command -v xelatex &> /dev/null; then
echo "Not found xelatex command" 1>&2
echo "Please install the 'texlive-xetex' and 'latex-cjk-all' package" 1>&2
exit 1
fi
pandoc "$INPUT" \
-f markdown \
-t pdf \
--pdf-engine=xelatex \
-V mainfont="NanumGothic" \
-V CJKmainfont="NanumGothic" \
-o "$OUTPUT"
xelatex not found
The following error may occur:
xelatexnot found. Please select a different ``--pdf-engine`` or installxelatex-- see also ``/usr/share/doc/pandoc/README.Debian
Install it as follows:
Test it with the following command:
File `ctexhook.sty' not found.
The following error occurs:
Error producing PDF.
! LaTeX Error: File `ctexhook.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
Enter file name:
! Emergency stop.
<read *>
l.55 \prg_new_conditional:Npnn
Setting page margins
Using the command line:
Markdown syntax
Center alignment
<p markdown="1">
사이에 입력한 내용은 모두 중앙 정렬된다.
</p>
<h3 markdown="1">
이미지 크기 조절
</h3>
```markdown
{width=90%}
New page
<h2 markdown="1">
[YAML Style Meta-Data](YAML_frontmatter.md)
</h2>
<ul markdown="1">
<li markdown="1">
[Writing Your Docs - MkDocs](https://www.mkdocs.org/user-guide/writing-your-docs/#yaml-style-meta-data)
</li>
</ul>
<p markdown="1">
[YAML전방주석](YAML_frontmatter.md) ([YAML Front Matter](YAML_frontmatter.md)) 에 대한 내용이다.
</p>
```yaml
---
title: My Document
summary: A brief description of my document.
authors:
- Waylan Limberg
- Tom Christie
date: 2018-07-10
some_url: https://example.com
---
Pandoc AST
Guidelines for writing a decent spec document for external release
For a Spec document PDF meant for external delivery, the key is a professional layout + table of contents + cover page.
The Pandoc + Eisvogel template combination is recommended.
- Markdown → LaTeX → PDF conversion
- Automatic generation of cover page, table of contents, page numbers, and header/footer
- Clean rendering of tables, code blocks, and diagrams
- Automated builds possible through CI/CD integration
## 설치
sudo apt install pandoc texlive-xetex texlive-lang-cjk
## Eisvogel 템플릿 설치
mkdir -p ~/.local/share/pandoc/templates
## https://github.com/Wandmalfarbe/pandoc-latex-template 에서 다운로드
## 또는 https://github.com/enhuiz/eisvogel 에서 릴리즈 ZIP 파일 다운로드 받고, "eisvogel.latex" 파일 1개를 복사하면 된다.
# 변환
pandoc 13_ai_platform_interface_summary_draft.md \
-o 13_ai_platform_interface_summary.pdf \
--template eisvogel \
--pdf-engine=xelatex \
-V mainfont="NanumBarunGothic" \
-V sansfont="NanumBarunGothic" \
-V monofont="NanumGothicCoding" \
-V lang=ko \
--toc \
--toc-depth=3 \
-V titlepage=true \
-V titlepage-color="0D47A1" \
-V titlepage-text-color="FFFFFF"
If you add metadata at the top of the Markdown file, the cover page is generated automatically:
Supported file formats
Input formats
The input format with the most support is an extended version of Markdown. Notwithstanding, pandoc can also read in the following formats:
- Creole
- DocBook
- EPUB
- FictionBook (FB2)
- Haddock
- HTML
- Jira wiki markup
- Journal Article Tag Suite (JATS)
- JSON
- LaTeX
- Lightweight markup language
- man
- Markdown: Strict, CommonMark, GitHub Flavored Markdown (GFM), MultiMarkdown (MMD) and Markdown Extra (PHP Extra) variants
- OpenDocument (ODT)
- OPML
- Office Open XML: Microsoft Word variant
- Org-mode
- reStructuredText
- Textile
- txt2tags (t2t)
- Wiki markup: MediaWiki, Muse, TikiWiki, TWiki and Vimwiki variants
Output formats
Pandoc can create files in the following output formats, which are not necessarily the same set of formats as the input formats:
- AsciiDoc
- ConTeXt
- DocBook: Versions 4 and 5
- EPUB: Versions 2 and 3
- FictionBook (FB2)
- Haddock
- HTML: HTML4 and HTML5 variants, respectively compliant with XHTML 1.0 Transitional and XHTML Strict
- InDesign ICML
- Jira wiki markup
- Journal Article Tag Suite (JATS)
- JSON
- LaTeX
- man
- Markdown: Strict, CommonMark, GitHub Flavored Markdown (GFM), MultiMarkdown (MMD) and Markdown Extra (PHP Extra) variants
- OpenDocument (ODT/ODF)
- OPML
- Office Open XML: Microsoft Word and Microsoft PowerPoint variants
- Org-mode
- PDF (needs a third-party add-on like ConTeXt, pdfroff, wkhtmltopdf, weasyprint or prince)
- Plain text
- reStructuredText
- Rich Text Format (RTF)
- TEI
- Texinfo
- Textile
- Web-based slideshows: LaTeX Beamer, Slideous, Slidy, DZSlides, reveal.js and S5 variants
- Wiki markup: DokuWiki, MediaWiki, Muse, TikiWiki, TWiki and Vimwiki variants
Examples
HTML Output:
MS Word Output:
PDF Output:
PDF Output with Font:
pandoc test.md -o test.pdf --pdf-engine=xelatex -V mainfont="Nanum Gothic"
pandoc test.md -f markdown -t pdf --pdf-engine=xelatex -V CJKmainfont="바탕" -o test.pdf
Troubleshooting
unexpected end of input
Pandoc died with exitcode "64" during conversion: Error at "/home/your/Project/mwfilter/cache/16387.wiki" (line 23, column 1):
unexpected end of input
An exit code 64 error from Pandoc usually means there is a problem with the input file. The "unexpected end of input" message indicates a syntactic or formatting problem in the file. In this case, the problem is in the /home/your/Project/mwfilter/cache/16387.wiki file.
Possible causes of this error include:
- Unclosed tag pairs: if elements such as lists, code blocks, or headers are not closed properly, the parser may reach an unexpected end.
- For example, this happens when a Tag pair like
...is mismatched; in many cases you need to check all TAG pairs before the line printed in the log.
- For example, this happens when a Tag pair like
Solutions:
- Open the file in a text editor and look for obvious formatting errors around line 23.
- Regenerate the
.wikifile, or check that its content is correct before conversion.
See also
- Markdown
- pypandoc
- MegaParse - a parser for every type of document
- lychee (link checker) - a fast asynchronous link checker written in Rust