aboutsummaryrefslogtreecommitdiff
path: root/markdown/lexer.go
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2025-12-14 17:50:33 +0000
committerAnhgelus Morhtuuzh <william@herges.fr>2025-12-14 17:50:33 +0000
commit3312977ebeff03edc5b1bc1a2f815cad6a1ba7b8 (patch)
tree419617345dba2da3d0b666d5993964ce75904efa /markdown/lexer.go
parent8edad5f9aee4625384485ad07180da751858839c (diff)
parent0c0c6fb6df755d8f53d353e8b941e22a6c474b60 (diff)
Merge pull request '[Feat] Custom replace' (#3) from feat/custom-replace into main
Reviewed-on: https://git.anhgelus.world/anhgelus/small-web/pulls/3
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 {