Documentation
¶
Overview ¶
Package render turns untrusted author markdown into safe HTML. Hostile READMEs are a primary XSS vector, so this package is the only path by which user content reaches a browser, and it is deliberately strict: goldmark with raw HTML disabled, then a bluemonday allowlist, then invisible/bidi Unicode rendered as visible placeholders.
Index ¶
Constants ¶
const MaxInputBytes = 1 << 20
MaxInputBytes caps rendering input (the instruction-file quota is 1 MB; give README the same ceiling).
Variables ¶
This section is empty.
Functions ¶
func RevealInvisible ¶
RevealInvisible replaces invisible characters in already-sanitized HTML with visible, escaped placeholders wrapped in a marker span. Text outside tags only — attribute values are left alone (they are already policy- filtered, and rewriting inside them could corrupt URLs).
Types ¶
type Options ¶
type Options struct {
// ImageProxy maps an absolute http(s) image URL to a same-origin proxy
// URL. nil keeps the
// placeholder; a returned false keeps the placeholder for that URL.
ImageProxy func(dest string) (string, bool)
}
Options tunes a Renderer. The zero value is the strict default: images become placeholders.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer converts markdown to sanitized HTML. Safe for concurrent use.
func NewWithOptions ¶
NewWithOptions builds a Renderer with the given options.