Implemented strikethrough text
This commit is contained in:
20
Render.go
20
Render.go
@ -257,11 +257,12 @@ func (r *renderer) writeText(markdown string) {
|
||||
codeStart = -1
|
||||
emStart = -1
|
||||
strongStart = -1
|
||||
strikeStart = -1
|
||||
parentheses = 0
|
||||
)
|
||||
|
||||
for {
|
||||
i := strings.IndexAny(markdown[searchStart:], "[]()`*_")
|
||||
i := strings.IndexAny(markdown[searchStart:], "[]()`*_~")
|
||||
|
||||
if i == -1 {
|
||||
r.WriteString(html.EscapeString(markdown[tokenStart:]))
|
||||
@ -342,6 +343,23 @@ func (r *renderer) writeText(markdown string) {
|
||||
tokenStart = i
|
||||
emStart = i + 1
|
||||
}
|
||||
|
||||
case '~':
|
||||
if i+1 >= len(markdown) || markdown[i+1] != '~' {
|
||||
continue
|
||||
}
|
||||
|
||||
if strikeStart != -1 {
|
||||
r.WriteString("<del>")
|
||||
r.WriteString(html.EscapeString(markdown[strikeStart:i]))
|
||||
r.WriteString("</del>")
|
||||
strikeStart = -1
|
||||
tokenStart = i + 2
|
||||
} else {
|
||||
r.WriteString(html.EscapeString(markdown[tokenStart:i]))
|
||||
tokenStart = i
|
||||
strikeStart = i + 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user