Documentation
¶
Overview ¶
Package note provides the core Note type, ID generation, and frontmatter parsing/serialisation for the nn Zettelkasten CLI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var KnownLinkTypes = map[string]bool{ "refines": true, "contradicts": true, "source-of": true, "extends": true, "supports": true, "questions": true, "governs": true, }
KnownLinkTypes is the canonical set of link relationship types. nn link --type warns when the type is not in this set.
Functions ¶
func BM25Scores ¶ added in v0.17.0
BM25Scores returns BM25 scores for each note against the query terms. inbound maps note ID to annotation strings from notes that link to it; those tokens are included at inboundWeight relative to body tokens. Only notes matching at least one query term are included.
func GenerateID ¶
func GenerateID() string
GenerateID returns a unique note ID in the format <14-digit-timestamp>-<4-digit-random>. crypto/rand provides the suffix. A process-local set detects and retries on the rare within-process collision (e.g. 200 concurrent goroutines in the same second).
func IsKnownLinkType ¶ added in v0.14.0
IsKnownLinkType reports whether t is in the canonical link type set.
func Tokenize ¶ added in v0.64.0
Tokenize splits text into lowercase tokens. Exported for use in match-reason computation.
func ValidTypes ¶ added in v0.18.0
func ValidTypes() []string
ValidTypes returns the list of recognised note type strings.
Types ¶
type Link ¶
type Link struct {
TargetID string
Annotation string
Type string // optional relationship type, e.g. "refines", "contradicts"
Status string // "draft" or "reviewed"; empty = reviewed (backward-compat for old links)
}
Link is an annotated outgoing link from one note to another.
type Note ¶
type Note struct {
// Frontmatter fields
ID string
Title string
Type Type
Status Status
Tags []string
AppliesWhen string
ExpiresWhen string
Expires *time.Time
Created time.Time
Modified time.Time
// Body is the Markdown content between the frontmatter and the ## Links section.
Body string
// Links are parsed from the ## Links section.
Links []Link
}
Note is the in-memory representation of a single Zettelkasten note.
func Parse ¶
Parse reads a Markdown file (with YAML frontmatter) and returns a Note. Returns an error if the frontmatter is invalid, the type is missing, or a bare link (without annotation) is found in the ## Links section.