Pandoc Markdown Cheat Sheet: Commands and Flags
For Pandoc Markdown going to GitHub-flavored Markdown, start with:
pandoc -f markdown -t gfm --wrap=none input.md -o output.md
-f selects the input reader, -t selects the output writer, and -o names the output file. --wrap=none avoids automatic source-line wrapping; it does not set the rendered page width. Keep your original file, because exporting can change syntax or discard structures the destination cannot express.
Commands to keep handy
Convert between Markdown dialects
# Pandoc Markdown to GitHub-flavored Markdown
pandoc -f markdown -t gfm --wrap=none input.md -o output.md
# Read and write Pandoc Markdown
pandoc -f markdown -t markdown --wrap=none input.md -o output.md
# Pandoc Markdown to CommonMark
pandoc -f markdown -t commonmark --wrap=none input.md -o output.md
These command forms were executed in the original October 18, 2026 test. The command check records their exit codes. They are separate alternatives, not a sequence to run over the same output.
Inspect supported extensions
pandoc --list-extensions=markdown
pandoc --list-extensions=gfm
A + in this listing means the extension is enabled by default for that format; - means it is disabled by default. Append an extension switch to the format on the side you intend to change. For example, -f markdown-footnotes disables footnote interpretation while reading, whereas a writer setting changes serialization after reading. The Pandoc User's Guide documents the reader, writer, and extension options.
Inspect what Pandoc actually parsed
pandoc -f markdown -t native input.md
Use this when a footnote, table, or heading attribute disappears. A structured element in the native output means the reader recognized it. If the supposed syntax is ordinary text there, changing only the output writer will not fix the input interpretation.
Markdown syntax reference
Use -f markdown for the Pandoc-specific extensions below. A different Markdown reader may interpret them differently.
| Element | Example | Practical note |
|---|---|---|
| Heading | # Title, ## Section, ### Detail |
Use levels to express structure. |
| Emphasis | *emphasis*, **strong** |
Keep delimiters next to the text. |
| Link | [Pandoc](https://pandoc.org/) |
Give the link a useful label. |
| Image |  |
Deliver the referenced file with the Markdown. |
| Inline code | `variable_name` |
Keeps punctuation literal. |
| Bullet item | - First item |
Put subsequent items on separate lines. |
| Numbered item | 1. First step |
Use a list for ordered steps. |
| Blockquote | > Quoted text |
Prefix the quoted lines. |
| Heading identifier | ## Setup {#setup} |
Pandoc extension; may not survive another writer. |
| Footnote reference | A claim.[^note] |
Add the definition below. |
| Inline math | $x^2$ |
The destination must also support math rendering. |
Fenced code
```python
print("hello")
```
The language label identifies the code. It does not execute it.
Pipe table
| Route | Result |
|:-------|-------:|
| Local | Kept |
| Remote | Review |
The colons request left and right alignment. This is suitable for a simple rectangular table. A cell spanning multiple rows or columns needs a richer representation or an explicit flattened schema.
Footnote
Check the export.[^audit]
[^audit]: Compare the table with the source.
A writer may change the note's label or presentation. In our GFM export, the footnote stayed a footnote but received a generated label.
Definition list
Term
: A definition with a concrete meaning.
Our Pandoc Markdown output kept the definition-list structure. Our GFM output kept the words but flattened the term and definition into ordinary text.
Display math
$$
y = mx + b
$$
Parsing the expression and displaying it are separate requirements. Check the final app's math support rather than assuming that recognizable delimiters guarantee a rendered equation.
Paragraphs and line breaks
Leave a blank line between paragraphs. For a forced break inside a paragraph, use two trailing spaces or another form supported by the destination. The Markdown line-break guide gives copyable examples and a renderer comparison.
Choose the output writer by the destination
The same parsed document can produce different Markdown. In the original Pandoc 3.11 test, the ordinary table and extended syntax changed as follows:
| Writer | Observed result | When to consider it |
|---|---|---|
markdown |
Kept definition syntax and math delimiters; rewrote the pipe table as a space-aligned table | An editable source using Pandoc extensions |
gfm |
Wrote the simple table with pipes; removed the explicit heading ID; flattened the definition; changed math markup | A GitHub-flavored Markdown destination |
commonmark |
Represented the simple table as HTML | A CommonMark destination that also accepts the emitted HTML |
These observations come from one shared dialect fixture, not from testing every feature on GitHub.com. See the fixture generator and executed Pandoc commands.
Do not judge preservation from visible words alone. A heading can keep its text while losing an explicit identifier used by links. A definition can retain its wording while losing the term-and-definition relationship.
Merged tables need special care
For the reduced HTML span-table fixture, the GFM writer used HTML with explicit span attributes. The restricted writer markdown_strict+pipe_tables-raw_html instead produced a pipe table with blank positions:
| **Subject** | | **Grade** |
|-------------|-----------|-----------|
| Physics | Practical | A |
| | Theory | B+ |
The text remains, but the shared “Physics” cell no longer has an explicit row span. If that relationship matters, keep a richer table or repeat the applicable label in each row after checking the source.
This local reproduction did not produce the historical [TABLE] placeholder discussed in Pandoc issue 11128. It establishes behavior for this fixture and version, not a fix for every reported table problem.
Fix the problem at the right stage
| Symptom | What to inspect | Next step |
|---|---|---|
| Footnote markup appears literally | Native output from the intended reader | Correct the reader or extension setting. |
| A table becomes HTML | Whether rows and cells are still present | Accept HTML or choose a compatible output contract. |
| Merged cells become blanks | Whether span relationships were lost | Preserve a richer representation or label each row explicitly. |
| Source lines wrap differently | The output text, not the browser width | Use --wrap=none if unwrapped source is wanted. |
| Metadata title is not a body heading | Whether the title is metadata or document content | Add a body heading when one is required; check standalone output separately. |
Starting from Word or PDF?
For DOCX with embedded images, use media extraction and deliver the assets with the Markdown. The Pandoc DOCX-to-Markdown image guide covers a tested portable directory layout and the difference between Markdown images and raw HTML images.
Pandoc cannot read PDF directly. If you have only a PDF, extract or recognize its content first. Use the Pandoc PDF workflow guide to choose between original source files, selectable PDF text, and OCR. Changing a Markdown writer cannot restore a page that extraction omitted.
For a quick review of the exported source and rendered document, open the result in Markovo's Markdown Reader, then validate it in the final destination. The Reader was not part of this Pandoc comparison.
Test scope and evidence
The syntax comparison ran on October 18, 2026, using Python 3.11.14 and Pandoc 3.11. It used two synthetic inputs:
dialect.md: heading attribute, footnote, definition list, ordinary table, fenced code, and math.issue-11128.html: a reduced HTML table with row and column spans.
The fixture generator contains both inputs. The Pandoc command record includes arguments, exit codes, and output locations. The copyable-command check records the article's original command examples.
The original full score file remains available. It also contains unrelated document-conversion experiments; those rows are not evidence for the syntax reference above. Its line-based table checks can miss intact HTML tables or accept text without preserving span semantics. They are not an overall quality score.
The basic syntax examples are a reference, not a claim that each example was independently tested in every renderer.


