Documentation
¶
Overview ¶
Package richtext handles rich-text content for togo (Action Text / Trix style): sanitize untrusted HTML to an XSS-safe allowlist, render Markdown to safe HTML, and derive plain-text excerpts for search/previews.
rt := richtext.FromMarkdown("# Hi\n\n<script>alert(1)</script> **bold**")
rt.HTML // sanitized: "<h1>Hi</h1>\n<p> <strong>bold</strong></p>"
rt.PlainText() // "Hi bold"
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderMarkdown ¶
RenderMarkdown converts Markdown to sanitized HTML.
Types ¶
type RichText ¶
RichText is a stored rich-text value: the raw input plus the sanitized HTML that is safe to render.
func FromMarkdown ¶
FromMarkdown builds RichText from Markdown source.
func (RichText) Excerpt ¶
Excerpt returns the first n characters of the plain text, with an ellipsis when truncated (cuts on a word boundary where possible).
func (RichText) MarshalJSON ¶
MarshalJSON / UnmarshalJSON keep raw + (re-sanitized) html in sync.
func (*RichText) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.