diff options
-rwxr-xr-x | emparse | 17 |
1 files changed, 6 insertions, 11 deletions
@@ -26,7 +26,7 @@ expectblock && /^===== .* =====$/ { heading(5, $0); next } expectblock && /^====== .* ======$/ { heading(6, $0); next } expectblock { newblock("p") } -openblock == "pre" { sub("^ ", ""); escape(); printf "%s\n", $0; next } +openblock == "pre" { sub("^ ", ""); $0 = escape($0); printf "%s\n", $0; next } openblock == "ul" && /^ - / { item(1, "ul", line) } openblock == "ol" && /^ [0-9a-z]+\. / { item(1, "ol", line) } @@ -48,7 +48,7 @@ openblock == "dl" && /^ .*: / { term(line) } { format($0) } # inline formatting function format(line) { - escape(line) + line = escape(line) n = split(line, w, "[ ]") for (i = 0; i <= n; i++) { if (w[i] == "") continue; @@ -206,13 +206,8 @@ function ref(v) { } function escape(s) { - if (s == "") { - gsub("&", "\\&") - gsub("<", "\\<") - gsub(">", "\\>") - } else { - gsub("&", "\\&", s) - gsub("<", "\\<", s) - gsub(">", "\\>", s) - } + gsub("&", "\\&", s) + gsub("<", "\\<", s) + gsub(">", "\\>", s) + return s } |