about summary refs log tree commit diff stats
path: root/adapter
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-02-05 15:34:31 +0100
committerbptato <nincsnevem662@gmail.com>2024-02-05 15:34:31 +0100
commitf127f93f92f0d82ef10f9aed9d9e238e134620ee (patch)
tree96d6a9f3ec0b2044c763ccfa80c835a395bbf416 /adapter
parentde4f007f1aaf3df25fd46839be76fc900a389d84 (diff)
downloadchawan-f127f93f92f0d82ef10f9aed9d9e238e134620ee.tar.gz
md2html: add support for strikethrough
Diffstat (limited to 'adapter')
-rw-r--r--adapter/format/md2html.nim8
1 files changed, 7 insertions, 1 deletions
diff --git a/adapter/format/md2html.nim b/adapter/format/md2html.nim
index cd9cebab..8e623585 100644
--- a/adapter/format/md2html.nim
+++ b/adapter/format/md2html.nim
@@ -45,7 +45,7 @@ proc getId(line: openArray[char]): string =
     inc i
 
 type InlineState = enum
-  isItalic, isBold, isCode, isComment
+  isItalic, isBold, isCode, isComment, isDel
 
 const AsciiAlphaNumeric = {'0'..'9', 'A'..'Z', 'a'..'z'}
 proc parseInline(line: openArray[char]) =
@@ -105,6 +105,12 @@ proc parseInline(line: openArray[char]) =
     elif c == '`':
       state.incl(isCode)
       append "<CODE>"
+    elif c == '~' and i + 1 < line.len and line[i + 1] == '~':
+      if state.toggle(isDel):
+        append "<DEL>"
+      else:
+        append "</DEL>"
+      inc i
     elif c == '!' and bs == bsNone and i + 1 < line.len and line[i + 1] == '[':
       image = true
     elif c == '[' and bs == bsNone: