Summary Files Commits Branches @commit @diff @stats
path: root / single.awk
diff options
context:
space:
mode:
Commitf9994c7860b91d2efe26c075064de7e63a995059 (patch)
Author
 Syndamia <kamen@syndamia.com>
2024-07-21 14:50:43 +0300
Committer
 Syndamia <kamen@syndamia.com>
2024-07-21 14:50:43 +0300
Files35927a4123fdab67432cde48d0cc6f80390c7897 /single.awk
csg-f9994c7860b91d2efe26c075064de7e63a995059.tar
csg-f9994c7860b91d2efe26c075064de7e63a995059.tar.gz
csg-f9994c7860b91d2efe26c075064de7e63a995059.zip
Parent5e30f3b091824471b229e7a68f04ff876e4e7703 (diff)
(single) Generalized emphasis
1 files changed, 12 insertions, 22 deletions
-rw-r--r--single.awk34
diff --git a/single.awk b/single.awk
index 4e2e19a..2908c32 100644
--- a/single.awk
+++ b/single.awk
@@ -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 }