-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Reproduce example:
package main
import (
"bytes"
"fmt"
mathjax "github.com/litao91/goldmark-mathjax"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/parser"
"github.com/yuin/goldmark/renderer/html"
)
func main() {
md := goldmark.New(
goldmark.WithExtensions(mathjax.MathJax),
goldmark.WithParserOptions(
parser.WithAutoHeadingID(),
),
goldmark.WithRendererOptions(
html.WithHardWraps(),
html.WithXHTML(),
),
)
// todo more control on the parsing process
var html bytes.Buffer
mdContent := []byte(`
- 现在考虑整数 $n$
$$
n = p_1 p_2 \ldots p_k = q_1 q_2 \ldots q_l
$$
`)
if err := md.Convert(mdContent, &html); err != nil {
fmt.Println(err)
}
fmt.Println(html.String())
}
Result:
$ go run main.go
panic: interface conversion: interface {} is nil, not *mathjax.mathBlockData
goroutine 1 [running]:
github.com/litao91/goldmark-mathjax.(*mathJaxBlockParser).Continue(0xc0002005b0?, {0x616678, 0xc000197280}, {0x615d38, 0xc0002005b0}, {0x615f38, 0xc000200690})
/home/pluveto/go/pkg/mod/github.com/litao91/goldmark-mathjax@v0.0.0-20210217064022-a43cf739a50f/block.go:47 +0x3b4
github.com/yuin/goldmark/parser.(*parser).parseBlocks(0xc00020b508, {0x616ad8, 0xc000197080}, {0x615d38, 0xc0002005b0}, {0x615f38, 0xc000200690})
/home/pluveto/go/pkg/mod/github.com/yuin/goldmark@v1.2.1/parser/parser.go:1063 +0x5b9
github.com/yuin/goldmark/parser.(*parser).Parse(0xc00020b508, {0x615d38, 0xc0002005b0}, {0x0, 0x0, 0x40ce45?})
/home/pluveto/go/pkg/mod/github.com/yuin/goldmark@v1.2.1/parser/parser.go:848 +0x14b
github.com/yuin/goldmark.(*markdown).Convert(0xc0001f42c0, {0xc000218000, 0x53, 0x53}, {0x6149a8, 0xc00012b080}, {0x0, 0x0, 0x0})
/home/pluveto/go/pkg/mod/github.com/yuin/goldmark@v1.2.1/markdown.go:116 +0xce
main.main()
/home/pluveto/repo/blog-ws/test/main.go:37 +0x347
exit status 2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels