wikilink

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: MIT Imports: 1 Imported by: 0

README

Go Reference Go codecov

goldmark-wikilink is an extension for the goldmark Markdown parser that supports parsing [[...]]-style wiki links.

Usage

To use goldmark-wikilink, import the wikilink package.

import wikilink "github.com/abhinav/goldmark-wikilink"

Then include the wiklink.Extender in the list of extensions you build your goldmark.Markdown with.

goldmark.New(
  &wiklink.Extender{}
  // ...
)

goldmark-wikilink provides control over destinations of wikilinks with the Resolver type. Specify a custom Resolver to the Extender when installing it.

goldmark.New(
  &wiklink.Extender{
    Resolver: myresolver,
  }
  // ...
)

Documentation

Overview

Deprecated: Use "go.abhg.dev/goldmark/wikilink" instead.

Index

Constants

This section is empty.

Variables

Kind is the kind of the wikilink AST node.

Functions

This section is empty.

Types

type Extender

type Extender = wikilink.Extender

Extender extends a goldmark Markdown object with support for parsing and rendering Wikilinks.

type Node

type Node = wikilink.Node

Node is a Wikilink AST node. Wikilinks have two components: the target and the label.

The target is the page to which this link points, and the label is the text that displays for this link.

For links in the following form, the label and the target are the same.

[[Foo bar]]

For links in the following form, the target is the portion of the link to the left of the "|", and the label is the portion to the right.

[[Foo bar|baz qux]]

type Parser

type Parser = wikilink.Parser

Parser parses wikilinks.

Install it on your goldmark Markdown object with Extender, or install it directly on your goldmark Parser by using the WithInlineParsers option.

wikilinkParser := util.Prioritized(&wikilink.Parser{...}, 199)
goldmarkParser.AddOptions(parser.WithInlineParsers(wikilinkParser))

Note that the priority for the wikilink parser must 199 or lower to take precednce over the plain Markdown link parser which has a priority of 200.

type Renderer

type Renderer = wikilink.Renderer

Renderer renders wikilinks as HTML.

Install it on your goldmark Markdown object with Extender, or directly on a goldmark Renderer by using the WithNodeRenderers option.

wikilinkRenderer := util.Prioritized(&wikilink.Renderer{...}, 199)
goldmarkRenderer.AddOptions(renderer.WithNodeRenderers(wikilinkRenderer))

type Resolver

type Resolver = wikilink.Resolver

Resolver resolves pages referenced by wikilinks to their destinations.

var DefaultResolver Resolver = wikilink.DefaultResolver

DefaultResolver is a minimal wiklink resolver that resolves to HTML pages relative to the source page.

For example,

[[Foo]]      // => "Foo.html"
[[Foo bar]]  // => "Foo bar.html"
[[foo/Bar]]  // => "foo/Bar.html"

Jump to

Keyboard shortcuts

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