Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit3bb1da2647

README.md

markdown

Markdown syntax highlighter. Pure (text) -> { Segment }. Mirrors the algorithm of the deleted Rust highlight_markdown / highlight_markdown_inline pair (renderer.rs pre-Phase-3): block-level pass over split_inclusive('\n') recognises fenced code (```), headings (#), blockquotes (>), bullet/ordered lists; an inline pass within each non-block line recognises inline code (...), bold (...), and links (text).

Exports

  • highlight(text: string) -> { Segment } — tokenize a Markdown string into colored segments for the zui code renderer. The module returns this function directly.

Types:

  • Segment = { text: string, color: string, monospace: boolean }

Usage

local highlight = require("@builtin::modules.zui.highlight.markdown")
local segments  = highlight("# Title\n**bold**\n")

Notes

  • The module-level color upvalues are reassigned at every highlighter entry so the inline helper sees the active palette without per-call args. Multiple concurrent calls are NOT safe — this module is designed for serial UI rendering.
  • Inline code reuses the code.string theme role; treat the two as the same colour band.
  • Fenced code (```) toggles a multi-line fence — the highlighter tracks fence state across the input.