slug

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package slug generates heading anchor ids the way GitHub does.

Goldmark's built-in generator turns underscores into dashes and drops non-ASCII characters, so links like `#implementation-attack_pattern` written against GitHub's ids don't resolve. GitHub keeps word characters (letters, digits, marks and the underscore) plus the dash, lowercases everything, turns spaces into dashes and drops the rest.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIDs

func NewIDs() parser.IDs

NewIDs returns a parser.IDs generating GitHub-compatible anchor ids.

func Slug

func Slug(value string) string

Slug converts a heading text into a GitHub-compatible anchor id.

Types

type IDs

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

IDs implements parser.IDs with GitHub's slug rules.

func (*IDs) Generate

func (s *IDs) Generate(value []byte, kind ast.NodeKind) []byte

Generate generates a new element id for the given value.

func (*IDs) Put

func (s *IDs) Put(value []byte)

Put puts a given element id to the used ids table.

Jump to

Keyboard shortcuts

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