document

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: MIT Imports: 4 Imported by: 0

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

View Source
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"`
}

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
}

Document is a parsed markdown source file.

func Open

func Open(path string) (*Document, error)

Open reads and parses a markdown file.

type Page

type Page struct {
	Size   string `yaml:"size"`
	Margin string `yaml:"margin"`
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL