summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgmi2html.sh33
1 files changed, 27 insertions, 6 deletions
diff --git a/gmi2html.sh b/gmi2html.sh
index 165e4c3..4f73526 100755
--- a/gmi2html.sh
+++ b/gmi2html.sh
@@ -14,8 +14,16 @@ GMI=$1
list=0
pre=0
quote=0
+empty_line=0
while read line; do
+
+ if [ -z "$line" ]; then
+ empty_line=1
+ else
+ empty_line=0
+ fi
+
# pre formatted text
if [ -n "$(sed -nE '/^[`]{3}/p' <<< $line)" ]; then
if [ $pre -eq 0 ]; then
@@ -55,13 +63,16 @@ while read line; do
fi
quote=1;
text=$(sed -E 's/^[>] (.+)$/\1/g' <<< $line)
- echo "$text"
+ echo "<p>$text</p>"
continue
else
if [ $quote -eq 1 ]; then
- echo "</blockquote></figure>"
+ if [ $empty_line -eq 1 ]; then
+ echo "</blockquote></figure>"
+ quote=0
+ continue
+ fi
fi
- quote=0;
fi
# single line modifiers
@@ -88,14 +99,24 @@ while read line; do
text=$href
fi
- echo "<p><a href='${href}' rel='noopener' target='_blank'>$text</a></p>"
+ if [ $quote -eq 1 ]; then
+ echo "— <a href='${href}' rel='noopener' target='_blank'>$text</a>"
+ else
+ echo "<p><a href='${href}' rel='noopener' target='_blank'>$text</a></p>"
+ fi
continue
fi
# skip blank lines
- if [ -z "$line" ]; then
+ if [ $empty_line -eq 1 ]; then
continue
fi
+
# default paragraphs
- echo "<p>$line</p>"
+ if [ $quote -eq 1 ]; then
+ echo "— $line"
+ else
+ echo "<p>$line</p>"
+ fi
+
done < $GMI