Documentation
¶
Overview ¶
Package wiki contains the shared Markdown/wiki parsing and normalization rules that define canonical Knowl workspace semantics.
Index ¶
- Constants
- Variables
- func Body(content string) string
- func BoundSourceSignals(source knowl.SourceSummary) knowl.SourceSummary
- func ConceptLinks(from knowl.PageID, content string) []knowl.LinkReference
- func IndexDestinations(content string, limit int) ([]string, bool)
- func IndexTargets(content string) ([]string, bool)
- func Links(from knowl.PageID, content string) []knowl.LinkReference
- func MarkdownTargets(content string) ([]string, bool)
- func MigrateLegacyEnvelope(metadata okf.Metadata) (okf.Metadata, bool, error)
- func NormalizePageTarget(target string) string
- func PageIDFromPath(path string) (knowl.PageID, bool)
- func ResolveIndexDestination(catalogPath, raw string) (target string, external bool, valid bool)
- func SourceDocument(content string) *knowl.SourceDocument
- func SourceRefs(content string) []string
- func SourceSignals(ctx context.Context, content []byte) (knowl.SourceSummary, error)
- type Frontmatter
- type Navigation
Constants ¶
const ( RuleLinkLimit = "link.limit" RuleLinkNonportable = "link.nonportable" RuleLinkUnsafe = "link.unsafe" )
Stable generated-navigation rules, independent of OKF structural violations.
Variables ¶
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
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 ¶ added in v0.3.0
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
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 ¶
IndexTargets extracts both wiki links and bare list-item targets from index content.
func Links ¶
func Links(from knowl.PageID, content string) []knowl.LinkReference
Links converts normalized page targets into unique wiki link references.
func MarkdownTargets ¶
MarkdownTargets extracts normalized wiki-link targets from Markdown.
func MigrateLegacyEnvelope ¶ added in v0.3.0
MigrateLegacyEnvelope moves the legacy flat Knowl-owned fields into the namespaced extension without changing standard OKF fields or user content.
func NormalizePageTarget ¶
NormalizePageTarget converts a wiki reference into a canonical page ID.
func PageIDFromPath ¶
PageIDFromPath derives the canonical page ID from a wiki Markdown path.
func ResolveIndexDestination ¶ added in v0.3.0
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 ¶
SourceRefs returns a deterministic, deduplicated source-ref list.
func SourceSignals ¶ added in v0.6.0
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 ¶ added in v0.6.0
type Navigation struct {
}
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.