DCsunset / pandoc-include

A pandoc filter to allow file and header inclusion
MIT License
67 stars 14 forks source link

support mdbook include syntax #34

Open tg-x opened 1 year ago

tg-x commented 1 year ago

It would be nice to have an option to support the mdbook include syntax, that'd help portability of markdown documents across tools (e.g. using mdbook to generate html and pandoc to generate pdf from the same markdown files)

tg-x commented 1 year ago

here's a regex to convert mdbook includes to pandoc-include format:

FORMAT=commonmark_x sed 's/{{#include *\([^}]\+\):\([^}]\+\)}}/!include\`format="$FORMAT", snippetStart="<!-- ANCHOR: \2 -->", snippetEnd="<!-- ANCHOR_END: \2 -->"\` "\1"/; s/\[\([^]]\+\)\](\([^)]\+\.md\)#\([^)]\+\))/[\1](#\3)/g; s/{{#include *\([^:}]\+\)}}/!include\`format="$FORMAT"\` "\1"/; s/\[\([^]]\+\)\](\([^)]\+\.md\)#\([^)]\+\))/[\1](#\3)/g'