I'd like to know how to compile multiple pandoc files into one output document, where each input file has a title block.
E.g. suppose I have two files:
ch1.md
:
% Chapter 1
% John Doe
% 1 Jan 2014
Here is chapter 1.
ch2.md
:
% Chapter 2
% Jane Smith
% 3 Jan 2014
Here is chapter 2.
Typically with multiple input files you can compile them by providing them to pandoc:
pandoc ch1.md ch2.md --standalone -o output.html
However pandoc concatenates the input files before compiling, meaning only the first title block (from ch1.md
) is styled appropriately.
I would like each title block to be styled appropriately (e.g. in html, the first line of the title block is styled with <h1 class="title">
, the second <h2 class="author">
and so on).
(Note: I have also tried compiling each chapter as standalone separately, then concatenating these together using pandoc
. This removes the title styling for chapters after 1, though keeps styling for the authors/date).
Why? I can:
- compile each chapter in its own separate document and the author/title/date is marked up appropriately
- compile the entire document together and author/title/date is marked up appropriately for each chapter (can use the
--chapters
option)
I could just specify the heading with '#' (h1), author with '##' (h2), and date with '###' (h3) in each chapter file directly but this means pandoc doesn't "know" what the title/heading/date of my document are, so (e.g.) if I compile to latex it won't use the \date{}
or \author{}
tags appropriately.