-
Notifications
You must be signed in to change notification settings - Fork 228
Pandoc as bashblog's markdown compiler
save a file Markdown
and add markdown_bin="./Markdown"
in .config
, viola! that's it. but the real thing is to write the Mardown
file properly.
The minimum working Markdown
file is:
#!/usr/bin/env sh
/usr/bin/pandoc -o - --quiet --from=markdown --to=html5" "$@"
but if you want TOC generation, things get pretty complicated. The issue is in the pandoc's internal definition of the switch -s
. the issue is explained in issue#180. but here's the script:
#!/usr/bin/env sh
/usr/bin/pandoc -o - --quiet --from=markdown --to=html5 --toc --toc-depth=6 -s --template="modified.html5" "$@" > body.tmp
cat body.tmp | grep -oP "<p[^>]*>.*?<\/p>" | head -1 > title.tmp
grep -v -F -f title.tmp body.tmp > html.tmp
cat title.tmp html.tmp
rm title.tmp body.tmp html.tmp
This script requires modified.html5
template to function properly. and here it is:
$if(toc)$
<nav id="$idprefix$TOC" role="doc-toc">
$if(toc-title)$
<h2 id="$idprefix$toc-title">$toc-title$</h2>
$endif$
$table-of-contents$
</nav>
$endif$
$body$
if saving it to the site's root directory doesn't work, try to find the default templates directory of pandoc on your system by pandoc -D .
and create a new template modified.html5
with the above code there.
There're many useful features of pandoc markdown, few of them are as follows:
--bibliography=mylib.bib --csl=ieee.csl --no-highlight --mathjax --metadata=link-citations:true
for more checkout the Official Manual