Repo containing scripts to be used with dovel, and git hooks that powers our web interface.
Author: brian (git@myr.sh)
Date: Wed Dec 27 10:19:57 2023 -0300
Parent: 2d73cf0
Updated markdown parser
diff --git a/aux.sh b/aux.sh
index aa55f47..47d8fb0 100755
--- a/aux.sh
+++ b/aux.sh
@@ -123,6 +123,8 @@ type() {
}
mdown() {
+ set -f
+
p="0"
pre="0"
ul="0"
@@ -157,10 +159,18 @@ mdown() {
"## "*) printf "<h2>%s</h2>\n" "$(type ${l#*\# })" ;;
"# "*) printf "<h1>%s</h1>\n" "$(type ${l#*\# })" ;;
"***"|"---"|"___") printf "<hr>\n" ;;
- "- "*|"* "*|"+ "*)
+ "- "*)
[ "$ul" = "0" ] && printf "<ul>\n" && ul="1"
printf "\t<li>%s</li>\n" "$(type ${l#- })"
;;
+ "* "*)
+ [ "$ul" = "0" ] && printf "<ul>\n" && ul="1"
+ printf "\t<li>%s</li>\n" "$(type ${l#\* })"
+ ;;
+ "+ "*)
+ [ "$ul" = "0" ] && printf "<ul>\n" && ul="1"
+ printf "\t<li>%s</li>\n" "$(type ${l#+ })"
+ ;;
[0-9]". "*)
[ "$ol" = "0" ] && printf "<ol>\n" && ol="1"
printf "\t<li>%s</li>\n" "$(type ${l#[0-9]. })"
@@ -170,5 +180,8 @@ mdown() {
esac
done
+ [ "$ul" -gt "0" ] && printf "\n</ul>\n"
+ [ "$ol" -gt "0" ] && printf "\n</ol>\n"
[ "$p" -gt "0" ] && printf "\n</p>\n"
+ set +f
}