asciiman: improve command escaping
This commit is contained in:
parent
9883caf849
commit
34460ca715
|
@ -32,7 +32,7 @@ function expand(s, attr) {
|
||||||
function escape(s) {
|
function escape(s) {
|
||||||
gsub(/\\/, "\\\\", s)
|
gsub(/\\/, "\\\\", s)
|
||||||
gsub(/-/, "\\-", s)
|
gsub(/-/, "\\-", s)
|
||||||
gsub(/[.]/, "\\.", s)
|
sub(/^[.']/, "\\\\\\&&", s)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,9 +80,6 @@ function inline(line) {
|
||||||
|
|
||||||
line = escape(expand(line))
|
line = escape(expand(line))
|
||||||
|
|
||||||
# Enable double-spacing after the end of a sentence.
|
|
||||||
gsub(/\\[.][[:space:]]+/, ".\n", s)
|
|
||||||
|
|
||||||
# Strip empty URL descriptions, otherwise useful for demarking the end.
|
# Strip empty URL descriptions, otherwise useful for demarking the end.
|
||||||
while (match(line, /[^[:space:]]+\[\]/)) {
|
while (match(line, /[^[:space:]]+\[\]/)) {
|
||||||
line = substr(line, 1, RSTART + RLENGTH - 3) \
|
line = substr(line, 1, RSTART + RLENGTH - 3) \
|
||||||
|
@ -118,6 +115,15 @@ function inline(line) {
|
||||||
substr(line, RSTART + RLENGTH)
|
substr(line, RSTART + RLENGTH)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Enable double-spacing after the end of a sentence.
|
||||||
|
gsub(/[.][[:space:]]+/, ".\n", line)
|
||||||
|
gsub(/[!][[:space:]]+/, "!\n", line)
|
||||||
|
gsub(/[?][[:space:]]+/, "?\n", line)
|
||||||
|
|
||||||
|
# Quote commands resulting from that, as well as from expand().
|
||||||
|
gsub(/\n[.]/, "\n\\\\\\&.", line)
|
||||||
|
gsub(/\n[']/, "\n\\\\\\&'", line)
|
||||||
|
|
||||||
sub(/[[:space:]]+[+]$/, "\n.br", line)
|
sub(/[[:space:]]+[+]$/, "\n.br", line)
|
||||||
print line
|
print line
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue