Discover Packages
git.sr.ht/~idmyn/goldmark-wikilink
package
module
Version:
v0.0.0-...-32cc922
Opens a new window with list of versions in this module.
Published: Sep 6, 2020
License: MIT
Opens a new window with license information.
Imports: 6
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
README
¶
goldmark-wikilink
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"}
}
Expand ▾
Collapse ▴
Documentation
¶
Wikilink is a goldmark extension to transform internal links [[looking like this]]
into html <a href="looking-like-this.html" class="wikilink">looking like this</a>.
Get returns a slice of wikilink destination slugs
Source Files
¶
Click to show internal directories.
Click to hide internal directories.