From b0434a614769bee0439322d2dba54ff213fab35c Mon Sep 17 00:00:00 2001
From: Case Duckworth
Date: Fri, 10 May 2024 08:50:12 -0500
Subject: Rename functions
---
jimmy | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/jimmy b/jimmy
index 26f95d5..ed87dc1 100755
--- a/jimmy
+++ b/jimmy
@@ -71,8 +71,7 @@ gmi() {
filter_buff() {
case "$1" in
(html)
- sed -e "s/$nl/\n/g" -e "s/$sp/ /g" | # fix whitespace
- sed 's#\*\([^*]*\)\*#\1#g' | # *strong*
+ sed 's#\*\([^*]*\)\*#\1#g' | # *strong*
sed 's#_\([^_]*\)_#\1#g' | # _emph_
sed 's#`\([^`]*\)`#\1
#' | # `code`
cat
@@ -91,17 +90,18 @@ filter_line() {
## Utility functions
-buffpush() {
+pushline() {
tag="$1"; shift
printf "$(eval echo "\$fmtline_$tag")" "$@" |
filter_line "$to" >> "$buff"
}
-buffclose() {
- b="$(cat<"$buff")"
+bufprint() {
+ b="$(cat<"$buff"|filter_buff "$to")"
test -n "$b" || return
- printf "$(eval echo "\$fmtbuff_$1")" "$b" | filter_buff "$to"
- :>"$buff"
+ printf "$(eval echo "\$fmtbuff_$1")" "$b" |
+ sed -e "s/$nl/\n/g" -e "s/$sp/ /g" # fix whitespace
+ : > "$buff"
}
## Where the magic happens
@@ -111,7 +111,7 @@ process() {
do
if $verbatim && test "$sigil" != '```'
then
- buffpush verb "$sigil $line"
+ pushline verb "$sigil $line"
continue
fi
@@ -119,11 +119,11 @@ process() {
('```')
if $verbatim
then
- buffclose verb
+ bufprint verb
verbatim=false
prev=
else
- buffclose "$prev"
+ bufprint "$prev"
verbatim=true
fi
continue
@@ -133,7 +133,7 @@ process() {
read -r url title < "$lbuf"
if test "$curr" = para
then
- buffpush plnk "$url" "$title"
+ pushline plnk "$url" "$title"
continue
else curr=link
fi
@@ -148,22 +148,22 @@ process() {
;;
esac
- test "$curr" = "$prev" || buffclose "$prev"
+ test "$curr" = "$prev" || bufprint "$prev"
prev="$curr"
if test "$curr" = verb
then
- buffpush "$curr" "$line"
+ pushline "$curr" "$line"
continue
fi
if test "$curr" = link
- then buffpush "$curr" "$url" "$title"
- else buffpush "$curr" "$line"
+ then pushline "$curr" "$url" "$title"
+ else pushline "$curr" "$line"
fi
done
- buffclose "$curr"
+ bufprint "$curr"
}
### Entry point
--
cgit 1.4.1-21-gabe81