From a781714767af8d02f8cdd663efe2d878a0d26735 Mon Sep 17 00:00:00 2001 From: Steph Enders Date: Mon, 11 Mar 2024 12:04:42 -0400 Subject: Add logic to attribute quotes The idea here is that you can do: > A quote Attribution or > A quote => link//to attribution And we'll wrap it in the figure properly --- gmi2html.sh | 33 +++++++++++++++++++++++++++------ 1 file 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 "

$text

" continue else if [ $quote -eq 1 ]; then - echo "" + if [ $empty_line -eq 1 ]; then + echo "" + quote=0 + continue + fi fi - quote=0; fi # single line modifiers @@ -88,14 +99,24 @@ while read line; do text=$href fi - echo "

$text

" + if [ $quote -eq 1 ]; then + echo "— $text" + else + echo "

$text

" + fi continue fi # skip blank lines - if [ -z "$line" ]; then + if [ $empty_line -eq 1 ]; then continue fi + # default paragraphs - echo "

$line

" + if [ $quote -eq 1 ]; then + echo "— $line" + else + echo "

$line

" + fi + done < $GMI -- cgit v1.2.3-54-g00ecf