pandoc output in markdown: how to add the metadata

Viewed 443

A process takes a file in markdown format, parses it with pandoc to AST, changes some words in the text, and writes the resulting pandoc structure back to a markdown file.

This works except that the metadata which is included in the original file and is parsed by the pandoc input (extension: Ext_yaml_metadata_block is set) but is not included in the markdown output (extension there is only writerSetextHeaders).

What additional extension are needed? Or, do I need a different output template, including something like $Meta$ (with the --- before and after)? Pointers to a solution greatly appreciated.

Should a template like this work?

$if(meta)$
---
$Meta$
---

$endif$

$if(titleblock)$ $titleblock$

$endif$ $for(header-includes)$ $header-includes$

$endfor$ $for(include-before)$ $include-before$

$endfor$ $if(toc)$ $table-of-contents$

$endif$ $body$ $for(include-after)$

$include-after$ $endfor$
1 Answers

It sound like you are missing the -s/--standalone flag (optStandalone in Haskell). Without this option pandoc just outputs Markdown snippets, not a full document.

Related