aboutsummaryrefslogtreecommitdiff
path: root/markdown/lexer.go
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2025-12-14 18:05:35 +0100
committerAnhgelus Morhtuuzh <william@herges.fr>2025-12-14 18:05:35 +0100
commita65b9cb6b2c7dc7b48b8076d5e463776f1de0cf1 (patch)
tree021a5d38fe1a6c9bd876114fd3b3f4a296737fbd /markdown/lexer.go
parent8edad5f9aee4625384485ad07180da751858839c (diff)
feat(markdown): custom replacer
Diffstat (limited to 'markdown/lexer.go')
-rw-r--r--markdown/lexer.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/markdown/lexer.go b/markdown/lexer.go
index b68bbf9..375ef7f 100644
--- a/markdown/lexer.go
+++ b/markdown/lexer.go
@@ -21,6 +21,7 @@ const (
lexerExternal lexerType = "external"
lexerLiteral lexerType = "literal"
+ lexerReplace lexerType = "replace"
)
type lexer struct {
@@ -63,7 +64,7 @@ func (l *lexers) String() string {
return s + "]"
}
-func lex(s string) *lexers {
+func lex(s string, opt *Option) *lexers {
lxs := &lexers{current: -1}
var lexs []lexer
var currentType lexerType
@@ -127,7 +128,11 @@ func lex(s string) *lexers {
fn(c, lexerList, nil)
default:
newLine = false
- fn(c, lexerLiteral, nil)
+ if _, ok := opt.Replaces[c]; ok {
+ fn(c, lexerReplace, func(c rune) bool { return false })
+ } else {
+ fn(c, lexerLiteral, nil)
+ }
}
}
if len(previous) > 0 {