diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2025-09-30 17:03:45 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2025-09-30 17:03:45 +0200 |
| commit | de803487db3f02946eee753d50db00e625888049 (patch) | |
| tree | 3324083e295e1f679b6925efe28345c7010fb0ac /mardown | |
| parent | 29dcf9acb98d1f4ebde3156ce7021b3b4e5d679c (diff) | |
feat(markdown): support escape
Diffstat (limited to 'mardown')
| -rw-r--r-- | mardown/lexer.go | 5 | ||||
| -rw-r--r-- | mardown/lexer_test.go | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/mardown/lexer.go b/mardown/lexer.go index 42519e7..62978ab 100644 --- a/mardown/lexer.go +++ b/mardown/lexer.go @@ -5,7 +5,8 @@ import "fmt" type lexerType string const ( - lexerBreak lexerType = "break" + lexerBreak lexerType = "break" + lexerEscape lexerType = "escape" lexerModifier lexerType = "modifier" lexerCode lexerType = "code" @@ -75,6 +76,8 @@ func lex(s string) *lexers { fn(c, lexerQuote) case '[', ']', '(', ')', '!': fn(c, lexerExternal) + case '\\': + fn(c, lexerEscape) default: fn(c, lexerLiteral) } diff --git a/mardown/lexer_test.go b/mardown/lexer_test.go index 296e9b9..f6a06d5 100644 --- a/mardown/lexer_test.go +++ b/mardown/lexer_test.go @@ -19,4 +19,8 @@ func TestLex(t *testing.T) { if lxs.String() != "Lexers[modifier(**) literal(hey) modifier(**) literal(, what's up?) ]" { t.Errorf("invalid lex, got %s", lxs) } + lxs = lex(`Xxx\_DarkEmperor\_xxX`) + if lxs.String() != `Lexers[literal(Xxx) escape(\) modifier(_) literal(DarkEmperor) escape(\) modifier(_) literal(xxX) ]` { + t.Errorf("invalid lex, got %s", lxs) + } } |
