Documentation
¶
Overview ¶
Package document parses a markdown source file with YAML frontmatter into a Document value. The Document only carries the data parsed off disk; rendering lives in internal/render and theme resolution in internal/theme.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Default = Config{ MDoc: true, Theme: "", Title: "Untitled", Author: "Anonymous", Tags: []string{}, Page: Page{}, Data: map[string]any{}, }
Default is applied when a file has no frontmatter or its frontmatter does not opt in with `mdoc: true`.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
MDoc bool `yaml:"mdoc"`
Theme string `yaml:"theme"`
Title string `yaml:"title"`
Author string `yaml:"author"`
Tags []string `yaml:"tags"`
Page Page `yaml:"page"`
Data map[string]any `yaml:"data"`
References []Reference `yaml:"references"`
Numbering Numbering `yaml:"numbering"`
Labels map[string]string `yaml:"labels"`
}
Config is the YAML frontmatter shape.
type Document ¶
type Document struct {
Config Config
Body string
// Path is the absolute path to the source file.
Path string
// Dir is the absolute directory containing the source file. Relative
// references inside the document (images, includes) resolve from here.
Dir string
// Includes lists the absolute paths of files spliced into Body via
// `:::include`, in include order. Empty for documents that use no includes.
// The watcher (live preview) and the bundler read it so a change to any
// chapter triggers a reload and every chapter lands in the .mdoc archive.
Includes []string
}
Document is a parsed markdown source file.
type Numbering ¶ added in v0.2.0
type Numbering struct {
Enabled bool `yaml:"enabled"`
}
Numbering configures automatic heading numbering. It is off by default so ordinary documents don't get "1", "1.1" prefixes; thesis/report documents opt in with `numbering: {enabled: true}`. A `:::toc` works either way (entries just carry no number when numbering is off).
type Page ¶
Page mirrors the relevant parts of CSS @page. Both fields are passed through verbatim into the theme's @page rule, so anything CSS accepts (named sizes like "A4" / "Letter", explicit "210mm 297mm", "A4 landscape", the four-value margin shorthand, etc.) is valid. Themes provide the fallback when a field is empty.
type Reference ¶ added in v0.2.0
type Reference struct {
Key string `yaml:"key"`
ID string `yaml:"id"`
Author string `yaml:"author"`
Title string `yaml:"title"`
Year string `yaml:"year"`
Publisher string `yaml:"publisher"`
Edition string `yaml:"edition"`
ISBN string `yaml:"isbn"`
URL string `yaml:"url"`
Text string `yaml:"text"`
}
Reference is one bibliography entry. Cited from the body with `[@<key>]` and listed by a `:::bibliography` directive. If Text is set it is used verbatim (the raw escape-hatch); otherwise the structured fields are assembled by the renderer. Both `key` and `id` name the citation key.