render

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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 HTML

func HTML(note []byte, opts Options) string

HTML renders note to HTML before it is sanitized: what the spec's fixtures pin.

func Render

func Render(note []byte, opts Options) string

Render renders note to sanitized HTML: what note.render returns.

func Sanitize

func Sanitize(h string) string

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.

Jump to

Keyboard shortcuts

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