diff options
author | John Ankarström <john@ankarstrom.se> | 2021-01-29 18:12:48 +0000 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-01-29 18:12:48 +0000 |
commit | 99e2817d51dfa45b59276e6d002c6dd95b9f4156 (patch) | |
tree | 5b3f99bbd5c68fd8968c19da9a4267ee0bcf050c | |
parent | a08db38f245f68bf218f55f7a7a58defe27ca054 (diff) | |
download | em-99e2817d51dfa45b59276e6d002c6dd95b9f4156.tar.gz |
Fix multi-word inline formatting
-rwxr-xr-x | em | 36 |
1 files changed, 20 insertions, 16 deletions
@@ -57,22 +57,26 @@ function format(line) { for (i = 0; i <= n; i++) { if (w[i] == "") continue; - if (match(w[i], "^`.+`$")) - printf "<tt>%s</tt>", substr(w[i], 2, RLENGTH-2) - else if (match(w[i], "^\\*.+\\*$")) - printf "<i>%s</i>", substr(w[i], 2, RLENGTH-2) - else if (match(w[i], "^_.+_$")) - printf "<b>%s</b>", substr(w[i], 2, RLENGTH-2) - else if (match(w[i], "^`.+`[.,:;?!]$")) - printf "<tt>%s</tt>%s", substr(w[i], 2, RLENGTH-3), substr(w[i], RLENGTH) - else if (match(w[i], "^\\*.+\\*[.,:;?!]$")) - printf "<i>%s</i>%s", substr(w[i], 2, RLENGTH-3), substr(w[i], RLENGTH) - else if (match(w[i], "^_.+_[.,:;?!]$")) - printf "<b>%s</b>%s", substr(w[i], 2, RLENGTH-3), substr(w[i], RLENGTH) - else - printf "%s", w[i] - if (i < n) - printf " " + if (match(w[i], "^`")) + w[i] = "<tt>" substr(w[i], 2) + else if (match(w[i], "^\\*")) + w[i] = "<i>" substr(w[i], 2) + else if (match(w[i], "^_")) + w[i] = "<b>" substr(w[i], 2) + if (match(w[i], "`$")) + w[i] = substr(w[i], 1, RLENGTH-2) "</tt>" + else if (match(w[i], "\\*$")) + w[i] = substr(w[i], 1, RLENGTH-2) "</i>" + else if (match(w[i], "_$")) + w[i] = substr(w[i], 1, RLENGTH-2) "</b>" + else if (match(w[i], "`[.,:;?!]$")) + w[i] = substr(w[i], 1, RSTART-1) "</tt>" substr(w[i], RSTART+1) + else if (match(w[i], "\\*\.$")) + w[i] = substr(w[i], 1, RSTART-1) "</i>" substr(w[i], RSTART+1) + else if (match(w[i], "_[.,:;?!]$")) + w[i] = substr(w[i], 1, RSTART-1) "</b>" substr(w[i], RSTART+1) + printf "%s", w[i] + if (i < n) printf " " } printf "\n" } |