render

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: 12 Imported by: 0

Documentation

Overview

Package render is the single rendering pipeline shared by `mdoc print` and `mdoc open`. It turns a parsed document + resolved theme into the final HTML string that paged.js will paginate inside Chromium.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(doc *document.Document, thm *theme.Theme, opts Options) (string, error)

Render runs the full pipeline: RenderThemed + shell wrap. The result is a complete HTML document Chromium can load directly and have paged.js paginate. Used by the print pipeline.

Types

type Options

type Options struct {
	// VendorBase is the URL prefix from which paged.js + KaTeX assets load.
	// Examples: "/_/vendor" for the preview server, or a file:// URL when
	// the print pipeline extracts vendor files to a temp directory.
	VendorBase string
	// BaseHref controls how relative URLs inside the document resolve.
	// Typically a file:// URL to the document's directory for print, or
	// the server origin for preview.
	BaseHref string
	// HeadInject is extra HTML appended to <head>, e.g. live-reload glue.
	HeadInject htmltmpl.HTML
	// Version is reported as System.Version inside templates.
	Version string
}

Options configure where browser-visible asset URLs point.

type SystemData

type SystemData struct {
	Date    string
	Time    string
	Version string
}

SystemData are values made available to templates that aren't part of the document's own frontmatter (timestamps, mdoc version, etc.).

type ThemeData

type ThemeData struct {
	Title  string
	Author string
	Tags   []string
	Page   document.Page
	Data   map[string]any
	Body   htmltmpl.HTML
	System SystemData
}

ThemeData is what theme templates and the markdown body template see.

func RenderThemed

func RenderThemed(doc *document.Document, thm *theme.Theme, opts Options) (string, ThemeData, error)

RenderThemed runs the markdown body template, Markdown -> HTML, and the theme template — but NOT the shell wrap. The result is the themed HTML snippet that paged.js will paginate. Used by the preview server, which hosts its own copy of paged.js on the client side.

Jump to

Keyboard shortcuts

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