wiki

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 16 Imported by: ? 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 wiki contains the shared Markdown/wiki parsing and normalization rules that define canonical Knowl workspace semantics.

Index

Constants

View Source
const (
	RuleLinkLimit       = "link.limit"
	RuleLinkNonportable = "link.nonportable"
	RuleLinkUnsafe      = "link.unsafe"
)

Stable generated-navigation rules, independent of OKF structural violations.

Variables

View Source
var ErrSourceSignalsInvalid = errors.New("invalid source signals")

ErrSourceSignalsInvalid identifies source bytes that are not valid UTF-8.

Functions

func Body added in v0.3.0

func Body(content string) string

Body returns the user-authored Markdown after a valid leading frontmatter block. Content without a complete leading block is returned unchanged.

func BoundSourceSignals added in v0.6.0

func BoundSourceSignals(source knowl.SourceSummary) knowl.SourceSummary

BoundSourceSignals clips semantic fields before parsing lexical query terms. Identity fields are preserved. Lists retain first-seen spelling/order; total semantic text is limited to 4096 runes and 16384 bytes, with 256-rune fields and at most 32 tags/headings. Body consumes the remaining priority budget.

func ConceptLinks(from knowl.PageID, content string) []knowl.LinkReference

ConceptLinks extracts bounded standard Markdown links to OKF concepts and resolves them relative to the canonical page ID. External, asset, anchor, unsafe, and malformed destinations are ignored.

func IndexDestinations added in v0.3.0

func IndexDestinations(content string, limit int) ([]string, bool)

IndexDestinations returns bounded raw internal-link candidates from an OKF catalog. Resolution remains the caller's responsibility because nested catalogs resolve relative paths from their own directory.

func IndexTargets

func IndexTargets(content string) ([]string, bool)

IndexTargets extracts both wiki links and bare list-item targets from index content.

func Links(from knowl.PageID, content string) []knowl.LinkReference

Links converts normalized page targets into unique wiki link references.

func MarkdownTargets

func MarkdownTargets(content string) ([]string, bool)

MarkdownTargets extracts normalized wiki-link targets from Markdown.

func MigrateLegacyEnvelope added in v0.3.0

func MigrateLegacyEnvelope(metadata okf.Metadata) (okf.Metadata, bool, error)

MigrateLegacyEnvelope moves the legacy flat Knowl-owned fields into the namespaced extension without changing standard OKF fields or user content.

func NormalizePageTarget

func NormalizePageTarget(target string) string

NormalizePageTarget converts a wiki reference into a canonical page ID.

func PageIDFromPath

func PageIDFromPath(path string) (knowl.PageID, bool)

PageIDFromPath derives the canonical page ID from a wiki Markdown path.

func ResolveIndexDestination added in v0.3.0

func ResolveIndexDestination(catalogPath, raw string) (target string, external bool, valid bool)

ResolveIndexDestination resolves one catalog destination to a bundle-relative Markdown path. External and anchor destinations are valid but do not participate in the catalog graph.

func SourceDocument added in v0.3.0

func SourceDocument(content string) *knowl.SourceDocument

SourceDocument returns a copy of optional structured source provenance.

func SourceRefs

func SourceRefs(content string) []string

SourceRefs returns a deterministic, deduplicated source-ref list.

func SourceSignals added in v0.6.0

func SourceSignals(ctx context.Context, content []byte) (knowl.SourceSummary, error)

SourceSignals extracts detached metadata and supported Markdown signals. It recognizes leading YAML, ATX/Setext headings and fenced/indented code; it does not implement full CommonMark. Callers bound source reads beforehand.

Types

type Frontmatter

type Frontmatter struct {
	ID             string                `yaml:"id"`
	Title          string                `yaml:"title"`
	Type           string                `yaml:"type"`
	SourceRefs     []string              `yaml:"source_refs"`
	SourceDocument *knowl.SourceDocument `yaml:"source_document,omitempty"`
	Legacy         bool                  `yaml:"-"`
}

Frontmatter is the bounded YAML metadata recognized on ordinary pages.

func FrontmatterFromMetadata added in v0.3.0

func FrontmatterFromMetadata(concept okf.Metadata) (Frontmatter, error)

FrontmatterFromMetadata extracts the Knowl envelope from already parsed OKF metadata without decoding the concept again.

func ParseFrontmatter

func ParseFrontmatter(content string) (Frontmatter, error)

ParseFrontmatter reads canonical namespaced Knowl metadata and retains deterministic compatibility with the legacy flat envelope.

type Navigation struct {
	Targets []string
	Rule    string
}

Navigation is bounded generated-page navigation, separate from OKF syntax validity. Targets are bundle-relative concept IDs; existence is a caller concern.

func InspectNavigation added in v0.6.0

func InspectNavigation(relative, body string, limit int) Navigation

InspectNavigation checks the Markdown body of a generated concept. Literal code and link destinations are never inspected as prose. It does not read or fetch destinations. A nonempty Rule rejects generated navigation, not OKF.

Jump to

Keyboard shortcuts

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