Documentation
¶
Index ¶
- Variables
- func BuildKazariEngine(ctx context.Context, cfg *config.CodeblocksSettings, projectDir string) (*kazari.Engine, error)
- func DarkModeSelector(cfg *config.CodeblocksSettings) string
- func EffectiveCodeThemes(cfg *config.CodeblocksSettings, projectDir string) (light, dark string)
- func ImageLookupForPage(page *engine.Page, processor *asset.ImageProcessor, ...) imagerender.ImageLookupFunc
- func KazariConfigKey(projectDir string) string
- func LazyLoadingEnabled(processor *asset.ImageProcessor) bool
- func LoadKazariConfig(projectDir string) (string, *kazari.FileConfig)
- type Renderer
- func (r *Renderer) Fingerprint() string
- func (r *Renderer) LinkRenderer() *linkrender.Renderer
- func (r *Renderer) Render(markdown string) (engine.RenderResult, error)
- func (r *Renderer) ResetFlags()
- func (r *Renderer) SetImageLazyLoading(enabled bool)
- func (r *Renderer) SetImageLookup(lookup imagerender.ImageLookupFunc)
- func (r *Renderer) SetLinkContext(page *engine.Page)
- type RendererConfig
Constants ¶
This section is empty.
Variables ¶
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 KazariConfigKey ¶ added in v1.8.0
KazariConfigKey identifies the project's Kazari config file by name and content, or returns "" without one. It is part of the renderer fingerprint, so a change to an option that alters only the code block HTML, such as lineNumbers, invalidates the page cache.
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 ¶
NewRendererWithConfig creates a markdown renderer with the provided blocked href schemes. Deprecated: use NewRendererFromConfig for full configuration.
func (*Renderer) Fingerprint ¶
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
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 ¶
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
// KazariConfigKey identifies the project's kazari.config.yaml (see
// KazariConfigKey); part of the fingerprint.
KazariConfigKey string
// DirectiveRegistry holds site/theme generic directives. Nil or empty
// no-ops the generic directive extension.
DirectiveRegistry *directive.Registry
// SourceLines marks blocks with their source line (data-sd-line), for an
// editor's scroll sync with the dev server's preview. Dev mode only.
SourceLines bool
}
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. |
|
sourceline
Package sourceline marks rendered blocks with the source line they start on, as a data-sd-line attribute, so an editor beside the dev server's preview can scroll the two together (Sarde Studio's scroll sync).
|
Package sourceline marks rendered blocks with the source line they start on, as a data-sd-line attribute, so an editor beside the dev server's preview can scroll the two together (Sarde Studio's scroll sync). |
|
Package fence is the one grammar for ":::" directive fence lines.
|
Package fence is the one grammar for ":::" directive fence lines. |