~idmyn/goldmark-wikilink

a [[wikilink]] extension for the goldmark markdown parser
32cc9229 — David Mynors 2 months ago
Handle case where no wikilinks are found
57d88d4c — David Mynors 2 months ago
Fix go.mod
721df530 — David Mynors 2 months ago
initial commit

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~idmyn/goldmark-wikilink
read/write
git@git.sr.ht:~idmyn/goldmark-wikilink

You can also use your local clone with git send-email.

A goldmark plugin for wikilinks adapted from github.com/dangoor/goldmark-wikilinks.

#Usage

package main

import (
	"bytes"

	"git.sr.ht/~idmyn/goldmark-wikilink"
	"github.com/yuin/goldmark"
	"github.com/yuin/goldmark/parser"
)

func main() {
	markdown := goldmark.New(
		goldmark.WithExtensions(
			wikilink.Wikilink,
		),
	)

	source := `foo [[bar baz]]`

	var buf bytes.Buffer
	context := parser.NewContext()
	if err := markdown.Convert([]byte(source), &buf, parser.WithContext(context)); err != nil {
		panic(err)
	}

	htmlOutput := buf.String() // "<p>foo <a href="bar-baz.html" class="wikilink">bar baz</a></p>"
	destinationSlugs := wikilink.Get(context) // []string{"bar-baz"}
}