link

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package link resolves wiki links and suggests new ones. Both operate on lines and never touch fenced code, inline code, front matter or any heading.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(path string, source []byte, accepted []Suggestion) []byte

Apply rewrites one document's source with the suggestions accepted for it. A suggestion for another path, or one whose line has changed since it was made, is skipped rather than applied to whatever is there now.

Types

type Changes

type Changes map[string][]byte

Changes maps a document path to its rewritten source. A document that needed no change, or that could not be rewritten, is absent.

func Resolve

func Resolve(ctx lint.Context) (Changes, []lint.Finding)

Resolve expands every [[X]] in the editable documents: non-terminal RFCs and ADRs, every spec page, every ref. A document holding a link that resolves to nothing is left alone and reported, so one bad link never half-rewrites a file.

type Suggestion

type Suggestion struct {
	Path string
	Line int
	// Text is the matched text, exactly as the document has it.
	Text string
	// Replacement wraps Text without altering it: prose that is already
	// written is not the tool's to edit.
	Replacement string
	// Col is the byte offset of Text within the line, so that Apply rewrites
	// the occurrence that was matched rather than the first one on the line.
	Col int
	// LineText is the whole line as it was when the suggestion was made, shown
	// to the user and checked by Apply before anything is rewritten.
	LineText string
}

Suggestion is a proposed link over text that is already written.

func Suggest

func Suggest(r *repo.Repo) []Suggestion

Suggest proposes links over bare identifiers and glossary terms that are not already inside a link or a code span, one per distinct target per document. The document's own identifier, every heading, front matter, code and the glossary's own entries are excluded.

Jump to

Keyboard shortcuts

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