Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofmodule highlight.module·originates fromworld 07158574-5…

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 (#), blockq…

byzero-proxy @ DESKTOP-DB3UJOJ·posted 2mo ago
What it does

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.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

ZuiHighlightMarkdown Module Markdown syntax highlighter. Pure `(text) -> { Segment }`. Mirrors the algorithm of the deleted Rust `highlight_markdown` / `highlight_markdown_inline` pair (renderer.rs pre-Phase-3): a 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](url)). Colors flow from `ui.getToken("code.<role>")` via the active theme. The module-level locals below are reassigned at every highlighter entry so the helpers (`highlightInline`) see the active palette without per-call args. Initial values match the deleted Rust constants verbatim. The module returns the highlighter function directly: local highlight = require("modules.highlight.markdown") local segments = highlight("# Title\n**bold**\n")

token(role: string, fallback: string) → string

Internal: resolve `code.<role>` from the active theme; fall back to the deleted Rust constant when no `ui` global or no theme exists.

argtypedescription
rolestring
fallbackstring

push(segments: ?, text: ?, color: ?) → void

argtypedescription
segments?
text?
color?

isDigit(b: number) → boolean

argtypedescription
bnumber

leadingWsLen(s: string) → number

argtypedescription
sstring

startsWith(s: string, prefix: string) → boolean

argtypedescription
sstring
prefixstring

highlightInline(segments: ?, text: ?) → void

Internal: walks a string and emits segments for inline code, bold, and links. Plain runs between markers are flushed with the default color.

argtypedescription
segments?
text?

flushPlain(upTo: ?) → void

argtypedescription
upTo?

highlightMarkdown(text: string) →

Tokenize a Markdown source string into colored text segments for the zui code renderer. Block-level pass recognises fenced code (```), headings (#), blockquotes (>), bullet and ordered lists; inline pass within each non-block line recognises inline code, bold, and links. and defaults to `""` when nil. for the zui code renderer.

argtypedescription
textstringThe Markdown source to highlight. Coerced via `tostring`

examples

local segments = highlight("# Title\n**bold**\n")
⌬ Types
Segment = { text: string, color: string, monospace: boolean }

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

3items
·
other · born here
▤file
▲ 0↑ born
backing path · modules/highlight.module/markdown.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.