diff options
| Commit | f9994c7860b91d2efe26c075064de7e63a995059 (patch) | |
|---|---|---|
| Author | 2024-07-21 14:50:43 +0300 | |
| Committer | 2024-07-21 14:50:43 +0300 | |
| Files | 35927a4123fdab67432cde48d0cc6f80390c7897 /single.awk | |
| csg-f9994c7860b91d2efe26c075064de7e63a995059.tar csg-f9994c7860b91d2efe26c075064de7e63a995059.tar.gz csg-f9994c7860b91d2efe26c075064de7e63a995059.zip | ||
| Parent | 5e30f3b091824471b229e7a68f04ff876e4e7703 (diff) | |
(single) Generalized emphasis
1 files changed, 12 insertions, 22 deletions
| -rw-r--r-- | single.awk | 34 |
@@ -10,7 +10,9 @@ # [ ] Code blocks # [x] Horizontal rules # [ ] Span elements -# [ ] Links +# [.] Links +# [x] Inline +# [ ] Reference # [x] Emphasis # [ ] Code # [ ] Images @@ -174,29 +176,17 @@ blankline { } # Emphasis -/__.+__/ { - while (match($0, /__/)) { - sub(/__/, "<strong>") - sub(/__/, "</strong>") +function surround(brace, opening, closing) { + while ($0 ~ brace ".*" brace) { + sub(brace, opening) + sub(brace, closing) } } -/\*\*.+\*\*/ { - while (match($0, /\*\*/)) { - sub(/\*\*/, "<strong>") - sub(/\*\*/, "</strong>") - } -} -/_[^_].+_/ { - while (match($0, /_/)) { - sub(/_/, "<em>") - sub(/_/, "</em>") - } -} -/\*[^_].+\*/ { - while (match($0, /\*/)) { - sub(/\*/, "<em>") - sub(/\*/, "</em>") - } +{ + surround("__", "<strong>", "</strong>") + surround("_", "<em>", "</em>") + surround("\\*\\*", "<strong>", "</strong>") + surround("\\*", "<em>", "</em>") } { print } |
