Documentation
¶
Overview ¶
Package markdown provides markdown rendering and processing utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer converts markdown content to HTML, extracts titles, and strips markdown to plain text. HTML output is sanitized using bluemonday to prevent XSS attacks from user-submitted markdown.
func New ¶
func New() *Renderer
New creates a new Renderer with default goldmark configuration and HTML sanitization.
func (*Renderer) ExtractHeadings ¶
ExtractHeadings walks the Goldmark AST and extracts H1-H3 headings with their auto-generated IDs and text content, suitable for table of contents rendering.
func (*Renderer) ExtractTitle ¶
ExtractTitle extracts the title from the first H1 heading in the markdown content. If no H1 is found, it returns an empty string.
func (*Renderer) RenderHTML ¶
RenderHTML parses the markdown source once, extracts H1-H3 headings from the AST for table of contents rendering, then renders the AST to sanitized HTML. This avoids the cost of parsing the same source twice compared to calling ToHTML and ExtractHeadings separately.
func (*Renderer) ToHTML ¶
ToHTML converts markdown source to sanitized HTML. The output is sanitized to prevent XSS from crafted markdown inputs.
func (*Renderer) ToPlainText ¶
ToPlainText strips markdown formatting and returns plain text content suitable for search indexing.