Documentation
¶
Overview ¶
Package okf is the Open Knowledge Format, publishable without the rest of keepsake.
Index ¶
- Constants
- func ExtractLinks(body, p string) []string
- func IsDecimal(s string) bool
- func PyReprString(s string) string
- func Reserved(path string) bool
- func Resolve(target, directory string) (string, bool)
- func Serialize(c Concept) (string, error)
- func Storable(c Concept) error
- func Validate(c Concept) []string
- type Concept
- type Map
- type NonFinite
- type Signals
- type YAMLError
Constants ¶
const ( Unverified = "unverified" MachineConfirmed = "machine-confirmed" HumanReviewed = "human-reviewed" )
The §5.3 trust tiers, lowest first.
const ( MaxPath = 1024 MaxBody = 256 * 1024 MaxTitle = 4096 )
Postgres limits in bytes, refused in advance so the agent gets a sentence instead of a driver error.
Variables ¶
This section is empty.
Functions ¶
func ExtractLinks ¶
ExtractLinks returns the concept paths body links to, deduplicated in first-seen order. It matches Python's (?<!!)\[[^\]]*\]\(\s*([^)\s]*)(?:\s+[^)]*)?\s*\) in linear time.
func IsDecimal ¶
IsDecimal is Python's str.isdecimal() over ASCII: non-empty and every byte a digit.
func PyReprString ¶
PyReprString is Python's repr(str): single quotes unless only double quotes avoid escaping.
func Reserved ¶ added in v0.4.0
Reserved reports whether path names index.md or log.md, which OKF reserves in every directory. A backslash counts as a separator, since a Windows export writes `a\index` as a/index.md.
func Serialize ¶
Serialize renders a concept as an OKF document, failing only on a non-finite float.
Types ¶
type Concept ¶
type Concept struct {
Path string
Type string
Title string
Description string
Body string
Frontmatter *Map
Links []string
Version int
}
Concept is a single knowledge unit: a path, its frontmatter and its markdown body.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is an insertion-ordered JSON object of string, bool, nil, json.Number, int, NonFinite, []any or *Map.
func (*Map) MarshalJSON ¶
func (*Map) UnmarshalJSON ¶
UnmarshalJSON walks tokens so that key order survives; a map[string]any would lose it.
type NonFinite ¶
type NonFinite string
NonFinite is a YAML .inf, -.inf or .nan. JSON cannot hold it, so it refuses to marshal.