about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2024-05-10 08:50:12 -0500
committerCase Duckworth2024-05-10 08:50:12 -0500
commitb0434a614769bee0439322d2dba54ff213fab35c (patch)
treef1459a2c1c40aba9e3b6ca03b087b53662bd3ba1
parentFix a typo (diff)
downloadjimmy-b0434a614769bee0439322d2dba54ff213fab35c.tar.gz
jimmy-b0434a614769bee0439322d2dba54ff213fab35c.zip
Rename functions
-rwxr-xr-xjimmy32
1 files changed, 16 insertions, 16 deletions
diff --git a/jimmy b/jimmy index 26f95d5..ed87dc1 100755 --- a/jimmy +++ b/jimmy
@@ -71,8 +71,7 @@ gmi() {
71filter_buff() { 71filter_buff() {
72 case "$1" in 72 case "$1" in
73 (html) 73 (html)
74 sed -e "s/$nl/\n/g" -e "s/$sp/ /g" | # fix whitespace 74 sed 's#\*\([^*]*\)\*#<b>\1</b>#g' | # *strong*
75 sed 's#\*\([^*]*\)\*#<b>\1</b>#g' | # *strong*
76 sed 's#_\([^_]*\)_#<i>\1</i>#g' | # _emph_ 75 sed 's#_\([^_]*\)_#<i>\1</i>#g' | # _emph_
77 sed 's#`\([^`]*\)`#<code>\1</code>#' | # `code` 76 sed 's#`\([^`]*\)`#<code>\1</code>#' | # `code`
78 cat 77 cat
@@ -91,17 +90,18 @@ filter_line() {
91 90
92## Utility functions 91## Utility functions
93 92
94buffpush() { 93pushline() {
95 tag="$1"; shift 94 tag="$1"; shift
96 printf "$(eval echo "\$fmtline_$tag")" "$@" | 95 printf "$(eval echo "\$fmtline_$tag")" "$@" |
97 filter_line "$to" >> "$buff" 96 filter_line "$to" >> "$buff"
98} 97}
99 98
100buffclose() { 99bufprint() {
101 b="$(cat<"$buff")" 100 b="$(cat<"$buff"|filter_buff "$to")"
102 test -n "$b" || return 101 test -n "$b" || return
103 printf "$(eval echo "\$fmtbuff_$1")" "$b" | filter_buff "$to" 102 printf "$(eval echo "\$fmtbuff_$1")" "$b" |
104 :>"$buff" 103 sed -e "s/$nl/\n/g" -e "s/$sp/ /g" # fix whitespace
104 : > "$buff"
105} 105}
106 106
107## Where the magic happens 107## Where the magic happens
@@ -111,7 +111,7 @@ process() {
111 do 111 do
112 if $verbatim && test "$sigil" != '```' 112 if $verbatim && test "$sigil" != '```'
113 then 113 then
114 buffpush verb "$sigil $line" 114 pushline verb "$sigil $line"
115 continue 115 continue
116 fi 116 fi
117 117
@@ -119,11 +119,11 @@ process() {
119 ('```') 119 ('```')
120 if $verbatim 120 if $verbatim
121 then 121 then
122 buffclose verb 122 bufprint verb
123 verbatim=false 123 verbatim=false
124 prev= 124 prev=
125 else 125 else
126 buffclose "$prev" 126 bufprint "$prev"
127 verbatim=true 127 verbatim=true
128 fi 128 fi
129 continue 129 continue
@@ -133,7 +133,7 @@ process() {
133 read -r url title < "$lbuf" 133 read -r url title < "$lbuf"
134 if test "$curr" = para 134 if test "$curr" = para
135 then 135 then
136 buffpush plnk "$url" "$title" 136 pushline plnk "$url" "$title"
137 continue 137 continue
138 else curr=link 138 else curr=link
139 fi 139 fi
@@ -148,22 +148,22 @@ process() {
148 ;; 148 ;;
149 esac 149 esac
150 150
151 test "$curr" = "$prev" || buffclose "$prev" 151 test "$curr" = "$prev" || bufprint "$prev"
152 prev="$curr" 152 prev="$curr"
153 153
154 if test "$curr" = verb 154 if test "$curr" = verb
155 then 155 then
156 buffpush "$curr" "$line" 156 pushline "$curr" "$line"
157 continue 157 continue
158 fi 158 fi
159 159
160 if test "$curr" = link 160 if test "$curr" = link
161 then buffpush "$curr" "$url" "$title" 161 then pushline "$curr" "$url" "$title"
162 else buffpush "$curr" "$line" 162 else pushline "$curr" "$line"
163 fi 163 fi
164 done 164 done
165 165
166 buffclose "$curr" 166 bufprint "$curr"
167} 167}
168 168
169### Entry point 169### Entry point