diff options
| Commit | 7587c94092f7e228fc0a0758b21986e5378a632c (patch) | |
|---|---|---|
| Author | 2024-07-23 08:41:43 +0300 | |
| Committer | 2024-07-23 08:41:43 +0300 | |
| Files | 98b55eefb0a4274b5d2a824f88677313a992d89c /single.awk | |
| csg-7587c94092f7e228fc0a0758b21986e5378a632c.tar csg-7587c94092f7e228fc0a0758b21986e5378a632c.tar.gz csg-7587c94092f7e228fc0a0758b21986e5378a632c.zip | ||
| Parent | c3e67c6dbc67185180bdc99a11dd68a0c40ff725 (diff) | |
(single) Replaced character classes with explicit characters
1 files changed, 17 insertions, 16 deletions
| -rw-r--r-- | single.awk | 33 |
@@ -31,6 +31,7 @@ # [ ] Multi-line # [ ] Fenced code blocks ```lang ``` # [ ] Tables +# No character classes, since they aren't supported on every system BEGIN { prev_blankline = blankline = 1 @@ -68,12 +69,12 @@ function autoinsert(arrname, isbefore) { blankline = 1 } -/[^[:blank:]]/ { +/[^ \t]/ { blankline = 0 } # Inline HTML -/^[[:blank:]]*<\/?[[:alnum:]]+/ { +/^[ \t]*<\/?[0-9A-Za-z]+/ { println() next } @@ -84,7 +85,7 @@ function autoinsert(arrname, isbefore) { ## gsub(/&(?![[:alnum:]#]+;)/, "&") while (match(substr($0, ampstart + 1), /&/)) { ampstart += RSTART - if (match(substr($0, ampstart), /&[[:alnum:]#]+;/)) { continue } + if (match(substr($0, ampstart), /&[0-9A-Za-z#]+;/)) { continue } $0 = substr($0, 1, ampstart - 1) "&" substr($0, ampstart + 1) } @@ -95,10 +96,10 @@ function autoinsert(arrname, isbefore) { } # Blockquote Part 1/2 -/^>[[:blank:]]*$/ { next } +/^>[ \t]*$/ { next } /^> / { level = 0 - while (match($0, /^> [[:blank:]]*/)) { + while (match($0, /^> [ \t]*/)) { $0 = substr($0, RLENGTH + 1) level += RSTART while (topStack("bq-level") > level) { @@ -117,12 +118,12 @@ function autoinsert(arrname, isbefore) { } # atx-style headers -/^[[:blank:]]*#+/ { +/^[ \t]*#+/ { match($0, /#+/) if (RLENGTH <= 6) { ## Remove prefix/suffix - gsub(/^[[:blank:]]*#+[[:blank:]]*/, "") - gsub(/[[:blank:]]*#+[[:blank:]]*$/, "") + gsub(/^[ \t]*#+[ \t]*/, "") + gsub(/[ \t]*#+[ \t]*$/, "") if (RLENGTH == 1) autoinsert(user_H1_BEFORE, 1) else if (RLENGTH == 2) autoinsert(user_H2_BEFORE, 1) @@ -147,7 +148,7 @@ function autoinsert(arrname, isbefore) { } } # setex-style headers -!prev_blankline && /^[[:blank:]]*(=|-)+[[:blank:]]*$/ { +!prev_blankline && /^[ \t]*(=|-)+[ \t]*$/ { sub(/^<p>/, "", prev) ## from paragraph logic hlevel = 1 + ($0 ~ /-/) @@ -166,7 +167,7 @@ function autoinsert(arrname, isbefore) { } # Horizontal rules -/^(-|\*|_) ?(-|\*|_) ?(-|\*|_|[[:blank:]])+$/ { +/^(-|\*|_) ?(-|\*|_) ?(-|\*|_|[ \t])+$/ { autoinsert(user_HR_BEFORE, 1) println("<hr>") autoinsert(user_HR_AFTER) @@ -176,12 +177,12 @@ function autoinsert(arrname, isbefore) { # Line break / $/ { - sub(/[[:blank:]]* $/, "</br>") + sub(/[ \t]* $/, "</br>") } # Code blocks -/^( |\t)[[:blank:]]*/ { +/^( |\t)[ \t]*/ { } # Unordered lists @@ -189,7 +190,7 @@ function abs(x) { return ((x < 0) ? -x : x) } !blankline && lengthStack("list-level") > 0 { match($0, /^ */) indent = RLENGTH - match($0, /(\*|\+|-|[[:digit:]]+\.) /) + match($0, /(\*|\+|-|[0-9]+\.) /) if (RLENGTH == -1) RLENGTH = 0 ## indent + RLENGTH = length(" * " or " 1. ") while (indent + RLENGTH < abs(topStack("list-level"))) { @@ -206,8 +207,8 @@ function abs(x) { return ((x < 0) ? -x : x) } popStack("list-level") } } -/^[[:blank:]]*(\*|\+|-|[[:digit:]]+\.) / { - match($0, /(\*|\+|-|[[:digit:]]+\.) /) +/^[ \t]*(\*|\+|-|[0-9]+\.) / { + match($0, /(\*|\+|-|[0-9]+\.) /) if (abs(topStack("list-level")) < RSTART) { if (RLENGTH > 2) { xl = "<ol>"; mult = -1 @@ -252,7 +253,7 @@ blankline { href = substr($0, astart + RSTART + 1, RLENGTH - 3) ## ...[...](xxxxx)... title = "" - if (match(href, /"[^"]*"[[:blank:]]*$/)) { + if (match(href, /"[^"]*"[ \t]*$/)) { title = " title=" substr(href, RSTART, RLENGTH) href = substr(href, 1, RSTART - 1) } |
