--- title: Hue Markdown Spec version: 0.2.6 date: 2026-11-15 license: CC-BY-SA 4.0 --- # Introduction ## What is Hue Markdown? Hue Markdown ("Hue") is a strict superset of [CommonMark 0.31.2] that adds: 1. **Spans**: colored text and background shades, `{red: like this}`. 2. **Boxes**: blocks whose border is drawn in the source with box-drawing or ASCII characters. 3. **Hue fences**: a fenced code block with the info string `hue`, whose content is rendered as Hue Markdown. 4. **Diff spans**: inserted and removed text, `{+: added}` and `{-: removed}`. 5. **Key caps**: keyboard keys and shortcuts, `[[Ctrl+C]]`. 6. **Progress bars**: `[======....] 60%`. 7. **Tasks** with more states than done and to do: `- [-]` in progress, `- [!]` blocked, `- [?]` question. 8. **Side-by-side boxes**: boxes drawn next to each other become columns. Hue's main design rule is that **the source must stay readable when it is not rendered.** Every construct in this document was chosen because it still looks like what it means in plain text. [CommonMark 0.31.2]: https://spec.commonmark.org/0.31.2/ ## Files Hue documents use the file extension `.hue.md`, for example `notes.hue.md`. Because the name ends in `.md`, tools that do not know Hue treat the file as ordinary Markdown. The media type is `text/markdown; variant=hue`. ## Conformance A conforming implementation: 1. renders every CommonMark 0.31.2 example exactly as it would without Hue (Hue adds syntax, it never changes the meaning of existing CommonMark), and 2. renders every example in this document as shown. ## About the examples Examples are written as in the CommonMark spec: Markdown source on the left (above the `.`), and the expected HTML on the right (below it). The HTML assumes a CommonMark-compliant renderer with raw HTML enabled. Renderers for other targets (terminal, plain text) must produce output with the same structure; see [Rendering](#rendering). # Tokens A **style** is a list of one or more **tokens** separated by spaces. Styles appear in spans (`{red bg-yellow: …}`) and in box labels (`┌─ red Title ─┐`). Tokens are case-sensitive. ## Colors There are seven **colors**: | Token | Meaning | |----------|---------| | `red` | red | | `orange` | orange | | `yellow` | yellow | | `green` | green | | `blue` | blue | | `purple` | purple | | `gray` | gray | ## Semantic aliases **Aliases** name what text *means*. Each alias maps to one color. Authors should prefer aliases, because they let renderers add meaning beyond color (an icon or an accessible label) and keep documents consistent. | Token | Color | Use for | |----------|----------|---------| | `danger` | `red` | errors, destructive actions, hard warnings | | `!` | `red` | short form of `danger` | | `warn` | `orange` | cautions | | `ok` | `green` | success, passing, done | | `info` | `blue` | neutral information | | `note` | `purple` | asides, remarks | | `muted` | `gray` | de-emphasized text | Aliases render exactly like their color: `{ok: x}` produces the same output as `{green: x}`. ## Backgrounds `bg-` followed by a color or alias is a **background token**, e.g. `bg-yellow` or `bg-warn`. ## Hex colors `#rgb` or `#rrggbb` (hexadecimal digits, either case) is a **hex text color**. `bg-#rgb` or `bg-#rrggbb` is a **hex background**. Hex colors are an escape hatch: they ignore the theme and are not checked for contrast, so authors should prefer the palette. Any other `#…` value is not a token. ## Combining tokens A style holds at most one text color and one background. If a style names several text colors (or several backgrounds), the last one wins. A palette color and a hex color of the same kind also replace each other, so the last one still wins. If **any** word in a style is not a token, the whole style is invalid, and the construct that contains it is not recognized. # Spans ## Syntax A **span** is: 1. a `{`, 2. a style, written on one line, at most 64 characters, 3. a `:`, 4. optional spaces (ignored), 5. the **content**: one or more characters of inline Markdown, 6. the `}` that matches the opening `{`. Braces are matched like parentheses: each `{` is paired with the next unpaired `}`. Backslash-escaped braces (`\{`, `\}`) do not count. The content is parsed as inline Markdown and may contain other spans. **Precedence.** Code spans, autolinks and raw HTML tags bind more tightly than spans, exactly as they bind more tightly than link text in CommonMark: braces inside them do not count. Spans bind more tightly than links and emphasis: braces are matched before links and emphasis are parsed, so neither can cross a span boundary. A `}` inside a link destination therefore closes the span; escape it as `\}` or percent-encode it as `%7D`. ## Basic spans A color: ```````````````````````````````` example {red: stop} .
stop
```````````````````````````````` An alias renders like its color: ```````````````````````````````` example Build {ok: passing}, deploy {!: blocked}. .Build passing, deploy blocked.
```````````````````````````````` All aliases: ```````````````````````````````` example {danger: a} {warn: b} {ok: c} {info: d} {note: e} {muted: f} .a b c d e f
```````````````````````````````` A background: ```````````````````````````````` example {bg-yellow: highlighted} .highlighted
```````````````````````````````` A background alias: ```````````````````````````````` example {bg-warn: careful} .careful
```````````````````````````````` Text color and background together: ```````````````````````````````` example {blue bg-gray: both} .both
```````````````````````````````` When a style names two text colors, the last one wins: ```````````````````````````````` example {red blue: x} .x
```````````````````````````````` Palette and hex colors replace each other too: ```````````````````````````````` example {#fff red: x} {red #fff: y} .x y
```````````````````````````````` ## Spacing The space after the colon is optional, and extra spaces are ignored: ```````````````````````````````` example {red:tight} {red: loose} .tight loose
```````````````````````````````` Spaces around tokens are allowed: ```````````````````````````````` example { ! : alert} .alert
```````````````````````````````` ## Hex colors ```````````````````````````````` example {#c0ffee: mint} {bg-#333: dark} {#C0FFEE bg-#000000: both} .mint dark both
```````````````````````````````` Hex colors must have 3 or 6 digits. Anything else is not a token, so the span is not recognized: ```````````````````````````````` example {#ffff: four} {#ggg: letters} {#fff;color:red: injection} .{#ffff: four} {#ggg: letters} {#fff;color:red: injection}
```````````````````````````````` ## Content Content is inline Markdown: ```````````````````````````````` example {red: **bold** and `code` and [a link](/url)} .bold and code and a link
outer inner outer
```````````````````````````````` A `}` inside a code span does not close the span: ```````````````````````````````` example {red: use `}` here} .use } here
a } b
```````````````````````````````` Balanced braces in the content are kept: ```````````````````````````````` example {red: f(x) = {x}} .f(x) = {x}
```````````````````````````````` Content may continue on the next line of the same paragraph: ```````````````````````````````` example {red: first line second line} .first line second line
```````````````````````````````` ## Precedence Emphasis cannot cross a span boundary: ```````````````````````````````` example {red: *a} b* .*a b*
```````````````````````````````` Emphasis around a span is fine: ```````````````````````````````` example *{red: a}* .a
```````````````````````````````` A span inside link text: ```````````````````````````````` example [{red: go}](/url) . ```````````````````````````````` Code spans bind more tightly than spans: ```````````````````````````````` example `{red: x}` .{red: x}
https://example.com/} and bold
```````````````````````````````` A span that starts inside link text and does not end there takes the closing bracket with it, so the link is not recognized: ```````````````````````````````` example [a {red: b](/url) c} .[a b](/url) c
```````````````````````````````` A `}` inside a link destination closes the span: ```````````````````````````````` example {red: [x](/a}) y} .[x](/a) y}
```````````````````````````````` Escape it to keep the link inside the span: ```````````````````````````````` example {red: [x](/a\}) y} .x y
```````````````````````````````` Spans are not recognized in code blocks: ```````````````````````````````` example {red: x} .{red: x}
````````````````````````````````
## Not a span
Ordinary text that looks a bit like a span stays as written. A word
that is not a token makes the whole style invalid:
```````````````````````````````` example
{a: 1} {key: value} {Red: x} {red reddish: x}
.
{a: 1} {key: value} {Red: x} {red reddish: x}
```````````````````````````````` No colon: ```````````````````````````````` example {red} {red x} .{red} {red x}
```````````````````````````````` Empty content: ```````````````````````````````` example {red:} {red: } .{red:} {red: }
```````````````````````````````` No matching `}`: ```````````````````````````````` example {red: never closed .{red: never closed
```````````````````````````````` An escaped opening brace: ```````````````````````````````` example \{red: x} .{red: x}
```````````````````````````````` A style may not span lines: ```````````````````````````````` example {red blue: x} .{red blue: x}
```````````````````````````````` # Boxes ## Syntax A **box** is a block made of three parts: 1. A **top border**: a corner (`┌`, `╭` or `+`), one or more horizontal characters (`─` or `-`), and an optional **label**. An optional closing corner (`┐`, `╮` or `+`) may be included after optional horizontal characters. If a closing corner is present, it must match the family of the opening corner (a `+` starts and ends with `+`; `┌` or `╭` end with `┐` or `╮`). 2. Zero or more **interior lines**, each starting with a side border (`│` or `|`). The right side border is optional. 3. A **bottom border**: a corner (`└`, `╰` or `+`), and one or more horizontal characters (`─` or `-`). An optional closing corner (`┘`, `╯` or `+`) may be included at the end. The top border may be indented by up to three spaces (four or more make it an indented code block). Spaces before the other lines are ignored, as are trailing spaces. The **label** has two parts: as many leading words as are valid tokens form the box's **style**, and the remaining words form its **title**. A label word that comes after the title starts is part of the title, even if it is a token. The **interior** is the content of the interior lines, with the left side border, one following space (if present), the right side border and trailing spaces removed. It is parsed as a sequence of blocks, like the content of a block quote. If any line between the top border and the bottom border does not start with a side border, or there is no bottom border, the lines do not form a box and are parsed as ordinary Markdown. A box can interrupt a paragraph. ## Basic boxes ```````````````````````````````` example ┌─ info ──────────┐ │ Hello, **box**. │ └─────────────────┘ .Hello, box.
Keep .env out of git.
Plain box
quiet
x
x
x
All good.
Rounded
ragged edges are fine
First point Second point
┌─ red ─+ │ x └───────┘
```````````````````````````````` ## Interior The interior holds any blocks: ```````````````````````````````` example ┌─ green ─────────┐ │ Steps: │ │ │ │ 1. Build │ │ 2. Test │ │ │ │ ```sh │ │ npm test │ │ ``` │ └─────────────────┘ .Steps:
npm test
` that holds both lines and displays them as two lines. Boxes nest: ```````````````````````````````` example ┌─ blue ───────┐ │ ┌─ red ──┐ │ │ │ inner │ │ │ └────────┘ │ └──────────────┘ .
inner
Before
x
After
```````````````````````````````` A box inside a list item: ```````````````````````````````` example - item ┌─ ok ─┐ │ x │ └──────┘ .item
x
```````````````````````````````` Indented four spaces, it is a code block: ```````````````````````````````` example ┌─ red ─┐ │ x │ └───────┘ .quoted
┌─ red ─┐
│ x │
└───────┘
````````````````````````````````
## Not a box
No bottom border:
```````````````````````````````` example
┌─ red ─┐
│ open
.
┌─ red ─┐ │ open
```````````````````````````````` A line without a side border: ```````````````````````````````` example ┌─ red ─┐ │ one two └───────┘ .┌─ red ─┐ │ one two └───────┘
```````````````````````````````` A top border without corners: ```````````````````````````````` example ── red ── │ x └───────┘ .── red ── │ x └───────┘
```````````````````````````````` # Hue fences Plain Markdown joins consecutive lines into one paragraph, which garbles a drawn box on platforms that don't support Hue. A fenced code block whose info string's first word is `hue` keeps its content as monospace text on those platforms. Hue renders the content as Hue Markdown, as if the fence were not there. ```````````````````````````````` example ```hue ┌─ ok ─┐ │ yes │ └──────┘ ``` .yes
x
```````````````````````````````` Other fences are ordinary code blocks: ```````````````````````````````` example ```md {red: x} ``` .{red: x}
````````````````````````````````
# Diff spans
A diff span marks inserted or removed text. It is a span whose style
is the single token `+` (inserted) or `-` (removed), and it follows
every span rule above: brace matching, Markdown inside, code spans and
escapes.
- `{+: content}` renders as `content`.
- `{-: content}` renders as `v0.2: Added slide mode, Removed legacy flag.
Enable fast O(n) scanning and drop slow path.
Added fn() { return 1 } helper
{+: literal} and {+:} and {-: unclosed
```````````````````````````````` # Key caps `[[Key]]` renders as `Key` when `Key` is a keyboard key or a chord of keys joined by `+`: 1. **Named keys** (case-insensitive): `Ctrl`, `Control`, `Shift`, `Alt`, `Option`, `Opt`, `Cmd`, `Command`, `Super`, `Meta`, `Win`, `Fn`, `Enter`, `Return`, `Esc`, `Escape`, `Tab`, `Space`, `Spacebar`, `Backspace`, `Bksp`, `Delete`, `Del`, `Insert`, `Ins`, `Up`, `Down`, `Left`, `Right`, `Home`, `End`, `PgUp`, `PageUp`, `PgDn`, `PageDown`, `CapsLock`, `Caps`, `NumLock`, `ScrollLock`, `PrtSc`, `PrintScreen`, `Pause`, `Break`, `Menu`, `Clear`, `F1`–`F24`. 2. **Single uppercase letter or key symbol**: `A`–`Z`, `/`, `?`, `+`, `-`, `=`, `~`, `⌘`, `⌥`, `⇧`, `⌃`, `⏎`, `⌫`, `⇥`, `⎋`, `↑`, `↓`, `←`, `→`. 3. **Key chords** joined by `+`: e.g., `[[Ctrl+C]]`, `[[Cmd+Shift+P]]`, `[[Alt+F4]]`, `[[Ctrl+1]]`, `[[Ctrl++]]`. Anything else between `[[` and `]]` stays literal text: wiki links (`[[Project Roadmap]]`), unknown words, lowercase single letters and digits (`[[a]]`, `[[0]]`). So does `[[` directly after a letter, a digit or a bracket (`arr[[0]]`), and `[[Key]]` directly followed by `]` or `(`. A key cap is at most 32 characters. Individual keys separated by text: ```````````````````````````````` example Press [[Ctrl]] + [[Shift]] + [[P]] to open the palette. .Press Ctrl + Shift + P to open the palette.
```````````````````````````````` Combined chord inside a single keycap: ```````````````````````````````` example Use [[Cmd+Shift+P]] or [[Alt+F4]] or [[Ctrl++]]. .Use Cmd+Shift+P or Alt+F4 or Ctrl++.
```````````````````````````````` Navigation, function, and symbol keys: ```````````````````````````````` example Hit [[Esc]], [[Enter]], [[Tab]], [[F5]], or [[?]]. .Hit Esc, Enter, Tab, F5, or ?.
```````````````````````````````` WikiLinks and unknown words are never touched: ```````````````````````````````` example See [[Project Roadmap]] and [[internal_doc]] for details. .See [[Project Roadmap]] and [[internal_doc]] for details.
```````````````````````````````` Array indexing and lowercase/digit tokens stay untouched: ```````````````````````````````` example Matrix value `a[[0]]` or [[0]] or [[a]] or [[1, 2]]. .Matrix value a[[0]] or [[0]] or [[a]] or [[1, 2]].
Literal [[Ctrl]] keycap.
```````````````````````````````` # Progress bars `[bar] NN%` renders as a progress bar: 1. **Bar characters**: `4` to `40` total characters inside `[...]`, consisting of `0..40` filled characters (`=`, `#`, `■`, `█`) followed by `0..40` empty characters (`.`, `-`, `_`, `░`, ` `), with at least one non-space character. 2. **Percentage**: Followed by optional whitespace and an integer `0`–`100` with `%`. 3. **Color thresholds**: - `100%` -> `green` (`hue-progress-green`) - `50%`–`99%` -> `blue` (`hue-progress-blue`) - `25%`–`49%` -> `orange` (`hue-progress-orange`) - `0%`–`24%` -> `red` (`hue-progress-red`) The bar must not directly follow `[` and the percentage must not be directly followed by `(` or `[`, so links and nested brackets keep their meaning. All four automatic color tiers: ```````````````````````````````` example Done: [==========] 100% Active: [======....] 60% Warmup: [===.......] 30% Low: [=.........] 10% .Done: 100% Active: 60% Warmup: 30% Low: 10%
```````````````````````````````` Zero percent progress bar: ```````````````````````````````` example Queued: [..........] 0% .Queued: 0%
```````````````````````````````` Hash and Unicode block characters also work: ```````````````````````````````` example Build: [####----] 50% .Build: 50%
```````````````````````````````` Brackets without a trailing percentage or shorter than 4 bar chars stay literal: ```````````````````````````````` example Not a bar: [====] and [==] 50% and [====] 150%. .Not a bar: [====] and [==] 50% and [====] 150%.
```````````````````````````````` # Tasks A list item whose text starts with a marker in brackets, followed by at least one space, is a task. Tasks extend the GitHub task list (`[ ]` and `[x]`) with three more states: | Marker | State | Color | HTML symbol | |--------|-------|-------|-------------| | `[ ]` | `todo` | `gray` | `☐` (☐) | | `[-]` | `progress` | `blue` | `◐` (◐) | | `[!]` | `blocked` | `red` | `!` | | `[?]` | `question` | `purple` | `?` | | `[x]` or `[X]` | `done` | `green` | `✓` (✓) | The item gets the classes `hue-task hue-task-