From f05b41c13db271ba40feb0a64005f86b44c7a9e8 Mon Sep 17 00:00:00 2001 From: bptato Date: Thu, 1 Feb 2024 17:01:13 +0100 Subject: md2html: improved underscore ignoring rules Only ignore when prev/next chars are not alnum. --- adapter/format/md2html.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'adapter/format') diff --git a/adapter/format/md2html.nim b/adapter/format/md2html.nim index 2dc14404..cd9cebab 100644 --- a/adapter/format/md2html.nim +++ b/adapter/format/md2html.nim @@ -47,7 +47,7 @@ proc getId(line: openArray[char]): string = type InlineState = enum isItalic, isBold, isCode, isComment -const AsciiWhitespace = {' ', '\t', '\n', '\r'} +const AsciiAlphaNumeric = {'0'..'9', 'A'..'Z', 'a'..'z'} proc parseInline(line: openArray[char]) = var state: set[InlineState] = {} var bs = bsNone @@ -88,7 +88,9 @@ proc parseInline(line: openArray[char]) = else: append c elif c == '\\': quote = true - elif c == '*' or c == '_' and (i == 0 or line[i - 1] in AsciiWhitespace): + elif c == '*' or c == '_' and + (i == 0 or line[i - 1] notin AsciiAlphaNumeric or + i + 1 >= line.len or line[i + 1] notin AsciiAlphaNumeric + {'_'}): if i + 1 < line.len and line[i + 1] == c: if state.toggle(isBold): append "" -- cgit 1.4.1-2-gfad0