From aa455eb896abf4c1c0580da1d9aba6e4a28365ac Mon Sep 17 00:00:00 2001 From: Jaromil Date: Sat, 20 May 2017 14:34:24 +0200 Subject: [PATCH] support only pandoc for markdown rendering dropped support for other renderers, simplifies code and make results consistent. using markdown_github flavor with html5 target --- render | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/render b/render index 1fbd92c..9394626 100755 --- a/render +++ b/render @@ -302,36 +302,28 @@ render_html() { # first pass marks the markdown parts and saves them separate mds=(`find . -name 'tmp.md*'`) - { test "${#mds}" = "0" } || { + [[ "${#mds}" = "0" ]] || { # second pass substituted saved parts with rendered markdown act -n "${#mds} markdown fields " # check which markdown parser is available in PATH - command -v pandoc > /dev/null - if [[ $? = 0 ]]; then parser="pandoc -f markdown_github -t html5" - else command -v maruku > /dev/null - if [[ $? = 0 ]]; then parser="maruku --html-frag" - else command -v markdown > /dev/null; - if [[ $? = 0 ]]; then parser=markdown - else command -v multimarkdown > /dev/null - if [[ $? = 0 ]]; then parser=multimarkdown - else - error "no markdown renderer installed, please install pandoc or equivalent" - return 1 - fi - fi - fi - fi + if command -v pandoc > /dev/null; then + parser="pandoc -f markdown_github -t html5" - # parses all html and renders each markdown in the html - for i in $mds; do - md=`basename $i` - newtemp="tmp.$RANDOM" - cat $tmp | awk ' + # parses all html and renders each markdown in the html + for i in $mds; do + md=`basename $i` + newtemp="tmp.$RANDOM" + cat $tmp | awk ' /^'"$md"'/ { system("cat '"$md"' | '"$parser"'"); next } { print $0; }' > $newtemp - rm $tmp; tmp=$newtemp - done + rm $tmp; tmp=$newtemp + done + + else + error "Required program not found: pandoc" + error "Install pandoc on this system to render markdown" + fi } cat $tmp