mirror of https://github.com/dyne/webnomad.git
support only pandoc for markdown rendering
dropped support for other renderers, simplifies code and make results consistent. using markdown_github flavor with html5 target
This commit is contained in:
parent
74f61144a7
commit
aa455eb896
38
render
38
render
|
|
@ -302,36 +302,28 @@ render_html() {
|
||||||
|
|
||||||
# first pass marks the markdown parts and saves them separate
|
# first pass marks the markdown parts and saves them separate
|
||||||
mds=(`find . -name 'tmp.md*'`)
|
mds=(`find . -name 'tmp.md*'`)
|
||||||
{ test "${#mds}" = "0" } || {
|
[[ "${#mds}" = "0" ]] || {
|
||||||
# second pass substituted saved parts with rendered markdown
|
# second pass substituted saved parts with rendered markdown
|
||||||
act -n "${#mds} markdown fields "
|
act -n "${#mds} markdown fields "
|
||||||
|
|
||||||
# check which markdown parser is available in PATH
|
# check which markdown parser is available in PATH
|
||||||
command -v pandoc > /dev/null
|
if command -v pandoc > /dev/null; then
|
||||||
if [[ $? = 0 ]]; then parser="pandoc -f markdown_github -t html5"
|
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
|
|
||||||
|
|
||||||
# parses all html and renders each markdown in the html
|
# parses all html and renders each markdown in the html
|
||||||
for i in $mds; do
|
for i in $mds; do
|
||||||
md=`basename $i`
|
md=`basename $i`
|
||||||
newtemp="tmp.$RANDOM"
|
newtemp="tmp.$RANDOM"
|
||||||
cat $tmp | awk '
|
cat $tmp | awk '
|
||||||
/^'"$md"'/ { system("cat '"$md"' | '"$parser"'"); next }
|
/^'"$md"'/ { system("cat '"$md"' | '"$parser"'"); next }
|
||||||
{ print $0; }' > $newtemp
|
{ print $0; }' > $newtemp
|
||||||
rm $tmp; tmp=$newtemp
|
rm $tmp; tmp=$newtemp
|
||||||
done
|
done
|
||||||
|
|
||||||
|
else
|
||||||
|
error "Required program not found: pandoc"
|
||||||
|
error "Install pandoc on this system to render markdown"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cat $tmp
|
cat $tmp
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue