Skip to content

Latest commit

 

History

History
50 lines (34 loc) · 1.19 KB

Embedding markdown recursively.md

File metadata and controls

50 lines (34 loc) · 1.19 KB
tags
english, tutorial, markdown

Embedding markdown recursively

Remixing @Oliver Matthews' answer. I made it work recursively but instead using a wikilink-like syntax ![[filepath]] that gets replaced with filepath.md content

Setup

Create the script parseMd

#!/usr/bin/env bash
perl -ne 's#^!\[\[(.+?)\]\].*#`'$0' "$1.md"`#e;print' "$@"
chmod +x parseMd

Using it

To embed path/filename.md use the syntax ![[path/filename]]

Now parse the main file

./parseMd main.md > result.md

To 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=11mm

More info on using pandoc to [[Export Markdown to PDF]]

Resources