diff options
-rwxr-xr-x | em | 27 |
1 files changed, 26 insertions, 1 deletions
@@ -52,6 +52,31 @@ function term(line, t) { # t is a local variable printf "<dt>%s</dt><dd>", t } +function format(line) { + n = split(line, w, "[ ]") + 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 " " + } + printf "\n" +} + BEGIN { expectblock = 1; itemlevel = 1 } END { breakblock() } @@ -85,4 +110,4 @@ block = "ol" && /^ [0-9]+\./ { item(5, "ol", line) } block = "ul" && /^ -/ { item(6, "ul", line) } block = "ol" && /^ [0-9]+\./ { item(6, "ol", line) } -{ print $0 } +{ format($0) } |