From f0899429d56849f8cdf58f53a8232e4433f6725e Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Thu, 2 Oct 2025 10:23:52 +0200 Subject: feat(markdown): support escape --- mardown/lexer.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'mardown/lexer.go') diff --git a/mardown/lexer.go b/mardown/lexer.go index c056460..64fa78b 100644 --- a/mardown/lexer.go +++ b/mardown/lexer.go @@ -7,8 +7,6 @@ type lexerType string const ( lexerBreak lexerType = "break" - lexerEscape lexerType = "escape" - lexerModifier lexerType = "modifier" lexerCode lexerType = "code" @@ -75,7 +73,17 @@ func lex(s string) *lexers { currentType = t previous += string(c) } + literalNext := false for _, c := range []rune(s) { + if literalNext { + fn(c, lexerLiteral) + literalNext = false + continue + } + if c == '\\' { + literalNext = true + continue + } switch c { case '*', '_': if (currentType != lexerModifier && len(previous) > 0) || @@ -96,8 +104,6 @@ func lex(s string) *lexers { fn(c, lexerQuote) case '[', ']', '(', ')', '!': fn(c, lexerExternal) - case '\\': - fn(c, lexerEscape) case '-', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.': fn(c, lexerList) default: -- cgit v1.2.3