Minimal inline markdown for UI text: bold and italic spans, nothing block-level.
**bold** and __bold__ render bold, *italic* and _italic_ italic (including the
combined ***both***), a backslash escapes a marker (\* stays a literal asterisk),
and anything unmatched stays literal text rather than vanishing.
Pure logic, no Pixi dependency: parseMarkdown turns a string into styled spans for
RichLabel to draw, and stripMarkdown recovers the plain text (for measuring,
accessibility names, or any widget that stays single-style). Headings, links, lists
and code spans are deliberately out - a game label needs emphasis inside a sentence,
not a document renderer.
An underscore run inside a word (treasure_map) is not emphasis, matching CommonMark;
asterisks always are (a*b*c italicizes b). Markers pair strictly sequentially per
kind (**a** **b** is two spans), so exotic nesting degrades to literal markers rather
than surprising styling.
Minimal inline markdown for UI text: bold and italic spans, nothing block-level.
**bold**and__bold__render bold,*italic*and_italic_italic (including the combined***both***), a backslash escapes a marker (\*stays a literal asterisk), and anything unmatched stays literal text rather than vanishing.Pure logic, no Pixi dependency:
parseMarkdownturns a string into styled spans forRichLabelto draw, andstripMarkdownrecovers the plain text (for measuring, accessibility names, or any widget that stays single-style). Headings, links, lists and code spans are deliberately out - a game label needs emphasis inside a sentence, not a document renderer.An underscore run inside a word (
treasure_map) is not emphasis, matching CommonMark; asterisks always are (a*b*citalicizesb). Markers pair strictly sequentially per kind (**a** **b**is two spans), so exotic nesting degrades to literal markers rather than surprising styling.Example