markdown

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 60 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KazariConfigFiles = []string{"kazari.config.yaml", "kazari.config.yml", "kazari.config.json"}

KazariConfigFiles are the file names Kazari loads from the project root, in its lookup order; the first one found is used.

Functions

func BuildKazariEngine

func BuildKazariEngine(ctx context.Context, cfg *config.CodeblocksSettings, projectDir string) (*kazari.Engine, error)

BuildKazariEngine creates a Kazari code block engine. The highlighter backend is selected by cfg.Engine: "chroma" for fast Go-native highlighting (ideal for dev/live-reload), "nuri" (default) for accurate TextMate-based highlighting matching VS Code output.

func DarkModeSelector added in v1.5.0

func DarkModeSelector(cfg *config.CodeblocksSettings) string

DarkModeSelector returns the CSS selector that scopes code blocks' dark theme: markdown.codeblocks.dark_mode_selector, or the attribute Sarde's theme toggle sets on <html> when that is empty.

func EffectiveCodeThemes added in v1.7.0

func EffectiveCodeThemes(cfg *config.CodeblocksSettings, projectDir string) (light, dark string)

EffectiveCodeThemes returns the code block themes the engine uses: the themes entry of the project's kazari.config.yaml when it has one, applied as Kazari applies it, else markdown.codeblocks.light_theme and dark_theme.

func ImageLookupForPage

func ImageLookupForPage(page *engine.Page, processor *asset.ImageProcessor, resolve func(string) string) imagerender.ImageLookupFunc

ImageLookupForPage creates a lookup function for a specific page's resources. resolve maps a root-relative URL to its final form, typically prefixing the site's base path; nil leaves URLs unchanged. It is applied to the fallback src and to every responsive variant, since the processor emits both root-relative (variant URLs live under /assets/images/).

func LazyLoadingEnabled added in v1.2.0

func LazyLoadingEnabled(processor *asset.ImageProcessor) bool

LazyLoadingEnabled reports the processor's site-wide lazy-loading setting (default true when unset or when there is no processor).

func LoadKazariConfig added in v1.7.0

func LoadKazariConfig(projectDir string) (string, *kazari.FileConfig)

LoadKazariConfig reads the project's Kazari config, the first of KazariConfigFiles that exists, and returns its file name and content. The config is nil when there is no file or it does not parse; Kazari's own loader reports a file that does not parse.

Types

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer handles markdown to HTML conversion with heading extraction. Implements engine.MarkdownRenderer.

func NewRenderer

func NewRenderer() *Renderer

NewRenderer creates a markdown renderer with all extensions and default security.

func NewRendererFromConfig

func NewRendererFromConfig(cfg RendererConfig) *Renderer

NewRendererFromConfig creates a markdown renderer from a full configuration.

func NewRendererWithConfig

func NewRendererWithConfig(blockedHrefSchemes []string) *Renderer

NewRendererWithConfig creates a markdown renderer with the provided blocked href schemes. Deprecated: use NewRendererFromConfig for full configuration.

func (*Renderer) Fingerprint

func (r *Renderer) Fingerprint() string

Fingerprint returns a content-addressed digest of the renderer's identity: registered extension types, config values, and Kazari CSS. The builder includes this in the page-cache key so the cache auto-invalidates when the rendering pipeline changes.

func (*Renderer) LinkRenderer

func (r *Renderer) LinkRenderer() *linkrender.Renderer

LinkRenderer returns the internal link renderer for external configuration (setting PageIndex, URLResolver, Policy).

func (*Renderer) Render

func (r *Renderer) Render(markdown string) (engine.RenderResult, error)

Render converts markdown to HTML, extracts headings, and returns both. Implements engine.MarkdownRenderer.

func (*Renderer) ResetFlags

func (r *Renderer) ResetFlags()

ResetFlags zeroes content feature flags before each page render.

func (*Renderer) SetImageLazyLoading added in v1.2.0

func (r *Renderer) SetImageLazyLoading(enabled bool)

SetImageLazyLoading propagates the site-wide lazy-loading setting to the image renderer so the plain-<img> fallback path honors it too (the first image per page always loads eagerly regardless).

func (*Renderer) SetImageLookup

func (r *Renderer) SetImageLookup(lookup imagerender.ImageLookupFunc)

SetImageLookup sets the lookup function for bundle-relative image processing. Swaps the lookup on the existing image renderer without rebuilding the Goldmark instance.

func (*Renderer) SetLinkContext

func (r *Renderer) SetLinkContext(page *engine.Page)

SetLinkContext sets the current page for internal link resolution. Must be called before Render() for each page.

type RendererConfig

type RendererConfig struct {
	BlockedHrefSchemes []string
	HeadingLinks       bool
	HeadingMinLevel    int
	HeadingMaxLevel    int
	// HardWraps renders a single newline inside a paragraph as <br>. Off by
	// default, matching CommonMark, so prose wrapped in the source reflows.
	HardWraps bool
	// AsideStyle selects the aside icon set ("classic" or "galaxy").
	// Empty behaves as classic.
	AsideStyle   string
	KazariEngine *kazari.Engine
	// DirectiveRegistry holds site/theme generic directives. Nil or empty
	// no-ops the generic directive extension.
	DirectiveRegistry *directive.Registry
}

RendererConfig controls markdown renderer behavior.

Directories

Path Synopsis
extensions
blockutil
Package blockutil provides shared helpers for container-style block directive parsers.
Package blockutil provides shared helpers for container-style block directive parsers.
codediff
Package codediff is a stub extension for organizational completeness.
Package codediff is a stub extension for organizational completeness.
genericdirective
Package genericdirective is the goldmark side of site- and theme-authored generic directives (internal/directive): one block parser and renderer handle every registered ::: directive, dispatching on the fence name.
Package genericdirective is the goldmark side of site- and theme-authored generic directives (internal/directive): one block parser and renderer handle every registered ::: directive, dispatching on the fence name.
kbd
Package fence is the one grammar for ":::" directive fence lines.
Package fence is the one grammar for ":::" directive fence lines.

Jump to

Keyboard shortcuts

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