From c2e31da8de71997c9454e4035b2139db8b4a7530 Mon Sep 17 00:00:00 2001 From: xplshn Date: Thu, 9 Jan 2025 23:00:45 -0300 Subject: Update genhtml.sh to use pandoc Signed-off-by: xplshn --- genhtml.sh | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/genhtml.sh b/genhtml.sh index 2a530e48..a1458696 100644 --- a/genhtml.sh +++ b/genhtml.sh @@ -1,32 +1,45 @@ #!/bin/sh -rm -f *.html docs/*.html +# Clean existing HTML files +rm -f ./*.html ./docs/*.html +# Convert root markdown files for i in *.md; do - { - title=${i%.md} - case ${i%.md} in index) title=home; esac - sed "s/@TITLE@/$title/g" header - smu $i - cat footer - } > ${i%.md}.html + [ -f "$i" ] || continue + title=${i%.md} + case ${i%.md} in + index) title=home ;; + esac + { + sed "s/@TITLE@/$title/g" header + pandoc -f markdown -t html "$i" + cat footer + } > "${i%.md}.html" done +# Generate docs/index.md echo 'Here lie the documentations for Alice Linux.' > docs/index.md + +# Add links to other documentation files for i in docs/*.md; do - case $i in docs/index.md) continue; esac - title=$(head -n1 $i) - i=${i#*/} - echo "- [$title](./${i%.md}.html)" >> docs/index.md + [ -f "$i" ] || continue + case $i in + docs/index.md) continue ;; + esac + title=$(head -n1 "$i") + i=${i#*/} + echo "- [$title](./${i%.md}.html)" >> docs/index.md done +# Convert documentation markdown files for i in docs/*.md; do - i=${i#*/} - { - sed "s/@TITLE@/docs/g" header - smu docs/$i - cat footer - } > docs/${i%.md}.html + [ -f "$i" ] || continue + i=${i#*/} + { + sed "s/@TITLE@/docs/g" header + pandoc -f markdown -t html "docs/$i" + cat footer + } > "docs/${i%.md}.html" done exit 0 -- cgit v1.2.3