Documentation
¶
Overview ¶
Package okf is the Open Knowledge Format, publishable without the rest of keepsake.
Index ¶
- Constants
- Variables
- func ExtractLinks(body, p string) []string
- func IsDecimal(s string) bool
- func PyReprString(s string) string
- func Resolve(target, directory string) (string, bool)
- func Serialize(c Concept) (string, error)
- func Validate(c Concept) []string
- type Concept
- type Map
- type NonFinite
- type YAMLError
Constants ¶
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 ¶
var ReservedPaths = map[string]bool{"index": true, "log": true}
ReservedPaths are the files a bundle export writes at its root, so no concept may hold one.
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.
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.