render

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 11 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 converts the representations of a page tree with asciidoctorg and titles its pages (PG-3, PG-8..10, MC-3): what every output needs, whatever it writes the pages to. The HTML site (package site) lays the result out as files; another output can take the same result.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Logger receives debug records (page durations) and Asciidoctor's own
	// messages, with the page and model location (asciidocLog); nil uses
	// slog.Default.
	Logger *slog.Logger
	// Pages decides the macros' links between pages (MC-18); nil uses the
	// tree's relative links (tree.Tree.Href), as in the HTML site.
	Pages macros.Pages
	// Views renders the views sysml-view shows (MC-21); nil leaves every
	// sysml-view a failure (MC-19).
	Views macros.Views
}

Options are how Tree renders.

type Page

type Page struct {
	Title          Title
	Own, Inherited []template.HTML // asciidoctorg output, secure safe mode
}

Page is a page's title and converted representations: its own, then the inherited ones, nearest first (PG-7). An empty ancestor page (PG-6) has a title and no representations.

type Result

type Result struct {
	Tree *tree.Tree
	// Pages has every page of Tree.Pages; the root (the landing page, PT-5)
	// has none.
	Pages map[*tree.Node]*Page
	// Warnings are the macros' warnings, each once per page and macro, in
	// the order first seen, failing macros included, with their location
	// filled when found (MC-7, MC-19).
	Warnings []macros.Warning
}

Result is a rendered page tree.

func Tree

func Tree(ctx context.Context, t *tree.Tree, opts Options) (*Result, error)

Tree converts the representations of every page of t, on every page that shows them, since macros may render them differently per page (MC-3), then titles the pages. Cancelling ctx stops the rendering (CLI-7): between pages, inside a conversion at asciidoctorg's next checkpoint (before each block is parsed or converted, and at each macro), and inside macro evaluations. A macro that fails leaves a placeholder on its page and a warning, and rendering goes on (MC-19); only a cancelled ctx or a rendering bug returns an error.

type Title

type Title struct {
	HTML, Text template.HTML
}

Title is a page title: HTML for the page heading, which may carry inline markup, and Text, without markup, for places that take plain text (a browser tab, the sidebar). Text is HTML-escaped already.

func PlainTitle

func PlainTitle(s string) Title

PlainTitle is the title s, which has no markup.

Jump to

Keyboard shortcuts

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