You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
602 B
Go
36 lines
602 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
// "fmt"
|
|
|
|
ofm "code.ndumas.com/ndumas/obsidian-markdown/goldmark"
|
|
"github.com/yuin/goldmark"
|
|
"github.com/yuin/goldmark/parser"
|
|
)
|
|
|
|
func main() {
|
|
m := goldmark.New(goldmark.WithExtensions(
|
|
ofm.ObsidianLinkExtension,
|
|
))
|
|
|
|
source := `
|
|
# Hello goldmark-extensions
|
|
this is a [[wikilink]] in text
|
|
|
|
[[wikilink]] starting a line
|
|
|
|
ending a line with a [[wikilink]]
|
|
`
|
|
|
|
var buf bytes.Buffer
|
|
|
|
context := parser.NewContext()
|
|
|
|
err := m.Convert([]byte(source), &buf, parser.WithContext(context))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
// fmt.Printf("%#+v\n", context)
|
|
}
|