Documentation
¶
Overview ¶
Package render renders a note to HTML for the reading view and embeds (ADR-0007; docs/specs/render.md): goldmark over the tree the index reads, with Obsidian's syntax drawn as the spec pins it, then sanitized.
Index ¶
Constants ¶
const ( MaxEmbeds = 100 MaxEmbedBytes = 4 << 20 )
MaxEmbeds and MaxEmbedBytes bound the note embeds one render draws, at every depth together: past either, an embed is a link, as one too deep is, so a few notes that embed each other many times over cannot make notesd render without end.
const MaxEmbedDepth = 3
MaxEmbedDepth is how deep embedded notes nest below the note rendered: embeds three levels down show their notes, and a fourth level is a link.
Variables ¶
This section is empty.
Functions ¶
func Sanitize ¶
Sanitize keeps only the elements and attributes of the spec's allowlist (docs/specs/render.md#sanitizer): what the renderer draws, and the harmless part of a note's raw HTML. It never adds markup and keeps the order of what it keeps. Text is passed through as the tokenizer read it, so entities stay as written, but for <; attribute values are written escaped.
Types ¶
type Options ¶
type Options struct {
// Path is the note's vault path; links resolve from its folder.
Path string
// Resolve returns the vault path a link target (without subpath or
// alias) leads to from the note at from, or "" when it is unresolved.
// An embedded note's links resolve from the embedded note.
Resolve func(from, target string) string
// File returns a vault file's content hash, or false when the vault
// has no file at path.
File func(path string) (hash string, ok bool)
// Note returns an embedded note's content, or false when there is
// none at path or it is larger than MaxEmbedBytes.
Note func(path string) ([]byte, bool)
}
Options say where a note sits and how to reach what it links to.