From 99e2817d51dfa45b59276e6d002c6dd95b9f4156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Fri, 29 Jan 2021 18:12:48 +0000 Subject: Fix multi-word inline formatting --- em | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/em b/em index 1b45893..4977ef3 100755 --- a/em +++ b/em @@ -57,22 +57,26 @@ function format(line) { for (i = 0; i <= n; i++) { if (w[i] == "") continue; - if (match(w[i], "^`.+`$")) - printf "%s", substr(w[i], 2, RLENGTH-2) - else if (match(w[i], "^\\*.+\\*$")) - printf "%s", substr(w[i], 2, RLENGTH-2) - else if (match(w[i], "^_.+_$")) - printf "%s", substr(w[i], 2, RLENGTH-2) - else if (match(w[i], "^`.+`[.,:;?!]$")) - printf "%s%s", substr(w[i], 2, RLENGTH-3), substr(w[i], RLENGTH) - else if (match(w[i], "^\\*.+\\*[.,:;?!]$")) - printf "%s%s", substr(w[i], 2, RLENGTH-3), substr(w[i], RLENGTH) - else if (match(w[i], "^_.+_[.,:;?!]$")) - printf "%s%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] = "" substr(w[i], 2) + else if (match(w[i], "^\\*")) + w[i] = "" substr(w[i], 2) + else if (match(w[i], "^_")) + w[i] = "" substr(w[i], 2) + if (match(w[i], "`$")) + w[i] = substr(w[i], 1, RLENGTH-2) "" + else if (match(w[i], "\\*$")) + w[i] = substr(w[i], 1, RLENGTH-2) "" + else if (match(w[i], "_$")) + w[i] = substr(w[i], 1, RLENGTH-2) "" + else if (match(w[i], "`[.,:;?!]$")) + w[i] = substr(w[i], 1, RSTART-1) "" substr(w[i], RSTART+1) + else if (match(w[i], "\\*\.$")) + w[i] = substr(w[i], 1, RSTART-1) "" substr(w[i], RSTART+1) + else if (match(w[i], "_[.,:;?!]$")) + w[i] = substr(w[i], 1, RSTART-1) "" substr(w[i], RSTART+1) + printf "%s", w[i] + if (i < n) printf " " } printf "\n" } -- cgit v1.2.3