This Makefile does the trick of producing a file with Pandoc from a directory of Markdown files, with some Markdown appended after the content of each Markdown file — by default three blocks of raw markup which will insert a pagebreak in DOCX, HTML or LaTeX output, but it can be taken from a file and so can be anything — before producing a single output file (by default a DOCX file) from the combined inputs with the appendage file inserted after each input file.
The content to append is taken from the file ./append.md
. If it doesn’t already exist it will be created with the following content:
````{=openxml}
<w:p><w:r><w:br w:type="page" /></w:r></w:p>
````
````{=html}
<div style="page-break-after: always;"></div>
````
````{=latex}
\newpage
````
The Makefile has been tested with GNU make and the dash shell. It should work with bash too.
The temporary directory can be removed by running make clean
.
There must be no space or hyphen characters in file or directory names!
The following make variables can be used to influence the selection of source files, the location of temporary copies and the name of the output DOCX file:
-------------------------------------------------------------------------------------------------
Variable Default Description
------------------- --------------------------------------------- -------------------------------
`MD_GLOB` `*.md` Glob pattern for Markdown files
`MD_DIR` `./md_files` Glob pattern for directory with
Markdown files
`MD_FILES` `$(wildcard $(MD_DIR)/$(MD_GLOB))` List of Markdown files
`APPEND_MD` `./append.md` Name of Markdown file to append
to each `MD_FILES`
`PANDOC` `pandoc` (Path to) Pandoc executable
`TO_FMT` (empty) The Pandoc output format
`FILTERS` (empty) List of Pandoc JSON filters
`FILTER_OPTS` `$(addprefix --filter=,$(FILTERS))` Expanded list of JSON filters
`LUA_FILTERS` (empty) List of Pandoc Lua filters
`LUA_FILTER_OPTS` `$(addprefix --lua-filter=,$(LUA_FILTERS))` Expanded list of Lua filters
`PANDOC_OPTS` (empty) (Other) options to Pandoc
`OUTPUT` `./combined.docx` (Path to) name of output (DOCX)
file
-------------------------------------------------------------------------------------------------
Feel free to adjust these variables as appropriate in your copy of the Makefile!
This software is Copyright (c) 2018 by Benct Philip Jonsson.
This is free software, licensed under:
The MIT (X11) License