Fix markdown preview $$ support (#31514)

close #31481

currently `$$A + B$$ test` will ignore text after $$ block

test text

![圖片](39b2974b-c0b6-48a0-87d0-5f4a13615eed)

before fix

![圖片](15469e4c-474d-4128-b46f-d6cadaafbd68)

after fix

![圖片](c1025eef-177f-4ade-988f-510e7039f3f9)

github display

![圖片](97cd1e10-ac94-4899-86d8-8e359ef1d694)

(cherry picked from commit f0033051d5ce07f5a18d2aacef6bfdca5fc69014)
This commit is contained in:
charles 2024-06-30 07:23:47 +08:00 committed by Earl Warren
parent e1b90212e4
commit f92591b825
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
6 changed files with 79 additions and 6 deletions

View file

@ -47,6 +47,12 @@ func (b *blockParser) Open(parent ast.Node, reader text.Reader, pc parser.Contex
}
idx := bytes.Index(line[pos+2:], endBytes)
if idx >= 0 {
// for case $$ ... $$ any other text
for i := pos + idx + 4; i < len(line); i++ {
if line[i] != ' ' && line[i] != '\n' {
return nil, parser.NoChildren
}
}
segment.Stop = segment.Start + idx + 2
reader.Advance(segment.Len() - 1)
segment.Start += 2