render

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package render turns a model.Document into one of three serializations behind a single Renderer interface: canonical JSON (the schema-stable contract the cache and Python wrapper read), Markdown (the LLM- and human-facing view), and plain text. Renderers are total functions over the model — they never re-extract or re-decide anything, and a null cell renders as JSON null, an empty Markdown cell, or a blank text column, never as 0.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownFormat = errors.New("render: unknown format")

ErrUnknownFormat is returned by For when the format name is not recognized.

Functions

This section is empty.

Types

type JSON

type JSON struct{}

JSON renders the canonical, schema-stable serialization: deterministic field order (from the struct tags), HTML left unescaped so free text stays readable, and a trailing newline. This is the format the cache stores and the differ and Python wrapper read.

func (JSON) Render

func (JSON) Render(doc *model.Document, w io.Writer) error

Render writes doc as indented JSON.

type Markdown

type Markdown struct{}

Markdown renders the LLM- and human-facing view: a document heading, each section as a `##` heading with its free text and tables, the financial statements as right-aligned Markdown tables, and a compact provenance footer.

func (Markdown) Render

func (Markdown) Render(doc *model.Document, w io.Writer) error

Render writes doc as Markdown.

type Renderer

type Renderer interface {
	Render(doc *model.Document, w io.Writer) error
}

Renderer writes one serialization of a Document to w.

func For

func For(format string) (Renderer, error)

For returns the renderer for a format name: "json" (the default), "md" / "markdown", or "text" / "txt".

type Text

type Text struct{}

Text renders plain text for terminals and grep, with no Markdown decoration: section titles upper-cased and underlined, statements as fixed-width aligned columns, and a blank column for a missing value (never 0).

func (Text) Render

func (Text) Render(doc *model.Document, w io.Writer) error

Render writes doc as plain text.

Jump to

Keyboard shortcuts

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