diff options
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 } |
