render

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package render turns an agent's Markdown into safe HTML.

Agent output is untrusted: it can be steered by prompt injection. It passes two independent layers before reaching a page. First goldmark with transformers that neutralize raw HTML and images; then a strict bluemonday allow-list. The HTML it returns contains no scripts, styles, event handlers, forms or images, and only http, https and mailto links.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChromaCSS

func ChromaCSS() string

ChromaCSS returns the stylesheet for highlighted code: the "github" style for the light theme and "github-dark" for the dark theme, each scoped to Bootstrap's data-bs-theme attribute. It is committed as assets/static/css/chroma.css; a test fails when the committed file is stale.

Pattern: Classes, Not Styles

Types

type Markdown

type Markdown struct {
	// contains filtered or unexported fields
}

Markdown renders Markdown to sanitized HTML. It is safe for concurrent use.

func NewMarkdown

func NewMarkdown() *Markdown

NewMarkdown builds the renderer.

func (*Markdown) Cached

func (m *Markdown) Cached() int

Cached is how many finished replies are kept.

func (*Markdown) Render

func (m *Markdown) Render(src string) template.HTML

Render converts src to sanitized HTML.

Pattern: Two Independent Filters

func (*Markdown) RenderFinal

func (m *Markdown) RenderFinal(src string) template.HTML

RenderFinal is Render for text that will not change again, a finished reply: the result is kept, so the next view of the conversation does not work it out again. Text that is still being written goes through Render, which keeps nothing: every snapshot of it is new.

Directories

Path Synopsis
cmd
chromacss command
Command chromacss writes the syntax-highlighting stylesheet.
Command chromacss writes the syntax-highlighting stylesheet.

Jump to

Keyboard shortcuts

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