Remixing @Oliver Matthews’
answer. I made it work recursively but instead using a wikilink-like
syntax ![[filepath]] that gets replaced with
filepath.md content
Create the script parseMd
#!/usr/bin/env bash
perl -ne 's#^!\[\[(.+?)\]\].*#`'$0' "$1.md"`#e;print' "$@"chmod +x parseMdTo embed path/filename.md use the syntax
![[path/filename]]
Now parse the main file
./parseMd main.md > result.mdTo export directly to pdf, using pandoc
pandoc <(./parseMd main.md) -o result.pdf --pdf-engine wkhtmltopdf \
--css styles.css \
-V margin-top=11mm \
-V margin-bottom=11mm \
-V margin-left=11mm \
-V margin-right=11mmMore info on using pandoc to Export Markdown to PDF