wikilink

package module
v0.0.0-...-32cc922 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2020 License: MIT Imports: 6 Imported by: 0

README

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"}
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Wikilink = &wikilink{}

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>.

Functions

func Get

func Get(pc parser.Context) []string

Get returns a slice of wikilink destination slugs

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL