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
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue