Documentation
¶
Index ¶
- func Clean(s string) string
- func Fence(id, body string) string
- func HTMLToText(src string) (text string, removed bool)
- func ListText(w io.Writer, msgs []provider.Message)
- func MessageText(w io.Writer, m *provider.Message) error
- func Write(w io.Writer, v any, o Options) error
- type Format
- type Options
- type TextWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clean ¶
Clean strips control characters (terminal escape sequences, bidi overrides) from untrusted text, keeping newlines and tabs.
func Fence ¶
Fence wraps untrusted body text in BEGIN/END markers. Any marker-like line inside the body is defused so a message cannot close the fence early.
func HTMLToText ¶
HTMLToText converts an HTML body to plain text, dropping content a human reader would not see (display:none, visibility:hidden, zero/tiny font size, zero opacity, text coloured like its background, off-screen indents, hidden attribute, mso-hide). This is the defence against "white text" prompt injection: the model should read what the human reads.
removed reports whether any non-whitespace hidden text was dropped.
Types ¶
type TextWriter ¶
TextWriter is implemented by result types that know how to print themselves.