markdown

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package markdown configures goldmark: CommonMark plus GFM, unique heading IDs and tryck's ::: directives.

Index

Constants

This section is empty.

Variables

View Source
var (
	KindAdmonition       = ast.NewNodeKind("Admonition")
	KindDetails          = ast.NewNodeKind("Details")
	KindTabs             = ast.NewNodeKind("Tabs")
	KindTab              = ast.NewNodeKind("Tab")
	KindGenericDirective = ast.NewNodeKind("GenericDirective")
)

Functions

func Slugify

func Slugify(s string) string

Slugify turns text into a URL- and anchor-safe identifier: lowercase, letters and digits kept (including non-ASCII letters), runs of spaces, dashes and underscores become one dash, other punctuation is dropped.

"Setup & Install" -> "setup-install"
"Översikt 2.0"    -> "översikt-20"

Types

type Admonition

type Admonition struct {
	ast.BaseBlock

	Variant string // note, tip, info, warning or danger
	// contains filtered or unexported fields
}

Admonition is :::note, :::tip, :::info, :::warning or :::danger. The kind is called Variant because goldmark nodes already have Kind and Type methods.

func (*Admonition) Dump

func (n *Admonition) Dump(source []byte, level int)

func (*Admonition) Kind

func (n *Admonition) Kind() ast.NodeKind

type Details

type Details struct {
	ast.BaseBlock
	// contains filtered or unexported fields
}

Details is :::details[summary].

func (*Details) Dump

func (n *Details) Dump(source []byte, level int)

func (*Details) Kind

func (n *Details) Kind() ast.NodeKind

type GenericDirective

type GenericDirective struct {
	ast.BaseBlock
	// contains filtered or unexported fields
}

GenericDirective is any directive name without a built-in renderer.

func (*GenericDirective) Dump

func (n *GenericDirective) Dump(source []byte, level int)

func (*GenericDirective) Kind

func (n *GenericDirective) Kind() ast.NodeKind

type Issue

type Issue struct {
	Severity diag.Severity
	Code     string
	Offset   int
	Message  string
}

Issue is a problem found while parsing, located by byte offset in the parsed source (-1 if unknown).

type Options

type Options struct {
	// UnsafeHTML passes raw HTML in Markdown through. Otherwise it is
	// replaced by an HTML comment.
	UnsafeHTML bool
	// Extenders add goldmark extensions, such as syntax highlighting.
	Extenders []plugin.MarkdownExtender
	// Directives render ::: names tryck does not know, by name.
	Directives map[string]plugin.DirectiveRenderer
	// SitePath maps root-absolute links in RenderInline to final URLs,
	// for example by adding the base path.
	SitePath func(string) string
}

Options configures the Markdown processor.

type Processor

type Processor struct {
	// contains filtered or unexported fields
}

Processor parses and renders Markdown. It is safe for concurrent use.

func New

func New(opts Options) *Processor

New returns a Processor configured from opts.

func (*Processor) Parse

func (p *Processor) Parse(source []byte) (ast.Node, []Issue)

Parse parses source into a document AST and reports directive problems and heading IDs that needed a -N suffix.

func (*Processor) Render

func (p *Processor) Render(doc ast.Node, source []byte) ([]byte, error)

Render renders a document parsed from source to an HTML fragment.

func (*Processor) RenderInline

func (p *Processor) RenderInline(s string) (string, error)

RenderInline renders a short Markdown string, such as a front matter description, and unwraps it if it is a single paragraph. Root-absolute link and image destinations ("/guide/") are passed through p.SitePath, when set, so they get the site's base path.

type Tab

type Tab struct {
	ast.BaseBlock
	Label  string
	Offset int
}

Tab is one "@tab Label" section inside Tabs.

func (*Tab) Dump

func (n *Tab) Dump(source []byte, level int)

func (*Tab) Kind

func (n *Tab) Kind() ast.NodeKind

type Tabs

type Tabs struct {
	ast.BaseBlock

	Index int // 1-based position among the page's tab sets, for element IDs
	// contains filtered or unexported fields
}

Tabs is ::::tabs, whose children are Tab nodes.

func (*Tabs) Dump

func (n *Tabs) Dump(source []byte, level int)

func (*Tabs) Kind

func (n *Tabs) Kind() ast.NodeKind

Jump to

Keyboard shortcuts

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