pandoc-include
pandoc-include copied to clipboard
support mdbook include syntax
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)
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'