Nueglow is Nue’s built-in syntax highlighter. Rather than shipping per-language grammar files, it recognizes universal code patterns — strings, comments, keywords, operators, numbers — and maps them to a small set of semantic HTML elements. Your CSS controls every color; no theme JSON files required.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nuejs/nue/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Export
glow(str, opts?)
The primary highlight function. Accepts a code string (or array of lines), applies syntax rules for the given language, and returns a <code> element string ready to embed inside a <pre>.
The source code to highlight. Either a multi-line string or an array of pre-split lines. Leading and trailing blank lines are stripped when a string is passed.
Highlight options. When a plain string is passed it is interpreted as the
language shorthand.<code language="{lang}">{highlighted lines}</code>.
When language is not detected, the attribute is language="*".
Examples:
Supported languages
Nueglow uses a universal rule set that works across all languages. In addition, these identifiers receive special treatment — extra keywords, custom token rules, or mixed-mode parsing:| Identifier(s) | Language | Special handling |
|---|---|---|
js, ts, jsx, tsx | JavaScript / TypeScript | Property access tokens (foo.bar) highlighted for js; JSX treated as mixed HTML |
html | HTML | Tag names highlighted as <strong>; mixed JS/CSS inside script and style |
jsx, php, astro, dhtml, vue, svelte, hb | Mixed HTML | Same HTML tag highlighting as html |
css | CSS | Hex colors → <strong>; !important → <label>; custom properties → <em> |
json | JSON | Keys ("foo":) → <b> |
yaml | YAML | Keys (foo:) → <b>; no common-word highlighting |
md, mdx, nuemark | Markdown | Line-by-line context detection (headings, quotes, code spans, front matter) |
python | Python | # line comments; extra keywords: None, nonlocal, lambda |
lua | Lua | -- line comments |
clojure | Clojure | ;; line comments |
go | Go | Extra keywords: chan, fallthrough |
cpp | C++ | Extra keywords: cout, cin, using, namespace |
// line comments.
Token-to-element mapping
Nueglow maps token types to plain HTML elements. Style them with ordinary CSS selectors onpre code:
| HTML element | Token type | Examples |
|---|---|---|
<strong> | Keywords, HTML tag names, CSS hex colors | function, import, <div>, #ff0000 |
<em> | String literals, numeric values, CSS custom properties | "hello", 'world', 42, --color |
<sup> | Line and block comments | // note, # remark, /* block */ |
<b> | Identifiers — variable names, function calls, property access | myVar, fetch(, obj.key |
<i> | Operators, brackets, and interpolation delimiters | =>, {, }, ( |
<label> | Decorators, annotations, Markdown section labels | @decorator, [section], !important |
<mark> | Inline marked text (single • markers) | ••highlighted•• |
<u> | Inline marked text (double • markers) | ••••double-marked•••• |
<ins> | Added lines (diff prefix +) | Whole-line wrapper |
<del> | Removed lines (diff prefix -) | Whole-line wrapper |
<dfn> | Focused/highlighted lines (prefix >) | Whole-line wrapper |
Multi-line comments
Nueglow detects block comments using opening and closing patterns and wraps every line of the comment in<sup>:
| Language(s) | Opening | Closing |
|---|---|---|
| C, JS, Java, CSS | /* | */ |
| Jinja/Nunjucks | {# | #} |
| HTML | <!-- | --> |
| Python, TOML | ''' | ''' |
| Ruby | =begin | =end |
Diff and focus markers
Whenprefix: true (the default), lines starting with +, -, or > are treated as diff markers. The prefix character is stripped and the line is wrapped in the corresponding element:
Inline marks
Surround any text with the• character (Alt+Q / Option+Q) to highlight it inline, independently of diff-line prefixes:
mark: false.
CSS custom properties
Nueglow does not ship a theme. Style the token elements directly in your stylesheet. The recommended approach uses CSS custom properties so you can swap themes by changing a few variables:Integration with Nuemark
Nueglow is the default code-block renderer inside Nuemark. Any fenced code block is automatically highlighted:glow() internally — no configuration needed.
To disable highlighting for a specific block, use a language of text or omit the language identifier entirely:
Standalone usage
Wrap theglow() output in a <pre> element for proper monospace display:
Lower-level exports
parseRow and renderRow are exported for testing purposes and advanced use cases where you need to highlight a single line: