render

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package render parses markdown to HTML using goldmark with GFM features and source-line annotations used by the browser scroll-sync client.

Index

Constants

View Source
const CSSCommon = `` /* 3656-byte string literal not displayed */

CSSCommon holds the shared markdown body styling.

View Source
const CSSDark = `` /* 390-byte string literal not displayed */

CSSDark holds the dark theme CSS custom properties.

View Source
const CSSLight = `` /* 390-byte string literal not displayed */

CSSLight holds the light theme CSS custom properties.

Variables

View Source
var Alerts goldmark.Extender = alertsExtension{}

Alerts is the goldmark extension that recognises GitHub-style alerts.

View Source
var KindAlert = ast.NewNodeKind("Alert")

KindAlert is the ast.NodeKind for Alert.

Functions

func BuildPage

func BuildPage(body, theme string, wsPort int, extraCSS string, colemak bool) string

BuildPage wraps an HTML body in the full preview page template.

theme selects the color palette: "dark" (default) or "light". wsPort > 0 embeds the WebSocket scroll/reload client; pass 0 for the static CLI preview, which omits the WebSocket script entirely. extraCSS is appended after the default CSS so it wins via cascade. colemak swaps the in-page nav keys from j/k/l to n/e/i.

func RenderBody

func RenderBody(filepath string) (string, error)

RenderBody reads filepath, strips YAML frontmatter, and renders it to an HTML body with data-line="N" attributes (1-indexed) on every block-level open tag whose origin can be traced to a source line.

On read error, it returns an HTML <p>Error reading file: ...</p> body and a non-nil error so callers can decide whether to surface the failure.

func RenderBytes

func RenderBytes(content []byte) string

RenderBytes is RenderBody for already-loaded content. Useful for tests and in-memory callers.

Types

type Alert added in v0.1.2

type Alert struct {
	ast.BaseBlock
	AlertKind []byte
}

Alert is the AST node for a GitHub-style alert blockquote — recognised when a blockquote's first line is "[!NOTE]" (or TIP / IMPORTANT / WARNING / CAUTION). Renders as `<div class="markdown-alert markdown-alert-...">`.

func (*Alert) Dump added in v0.1.2

func (n *Alert) Dump(source []byte, level int)

func (*Alert) Kind added in v0.1.2

func (n *Alert) Kind() ast.NodeKind

Jump to

Keyboard shortcuts

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