Skip to content

feat(render): color fenced code blocks by language - #11

Merged
tee8z merged 1 commit into
masterfrom
feat/code-highlighting
Oct 3, 2026
Merged

tee8z merged 1 commit into
masterfrom
feat/code-highlighting

Conversation

@tee8z

@tee8z tee8z commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Fenced code was rendered in one color. Public pages and previews now color comments, strings, numbers, keywords, types, functions, and attributes, in light and dark themes and without JavaScript. Rust gets the most attention (lifetimes, attributes, macros, raw strings, character literals); JavaScript/TypeScript, Python, Go, the C family, shell, SQL, TOML, YAML, JSON, Nix, Ruby, Dockerfile, and CSS get comments, strings, numbers, and keywords. HTML, XML, and diffs stay uncolored.

  • Presentation only. An article's identity HTML is unchanged, so approved revisions and their digests are unchanged. A known-language code block is carried as its own chunk in the article plan; token classes are added when a page or preview is projected. Text content of a colored block is exactly the escaped source.
  • Bounded. The scanner is one forward pass with bounded lookahead and no backtracking. Coloring only uses the room the plain page leaves under the rendered-HTML limit; a block that would not fit stays plain, so a page that built before still builds.
  • Frontend upgrade. The stylesheet gains the token colors, which changes the frontend bundle and therefore site identity. The frontend of releases 0.1.1 through 0.1.6 is frozen beside 0.1.0's, and startup verifies a retained site against either before installing the new presentation. The frozen copy is byte-identical to the bundle those releases serve and reproduces their pinned site digest.
  • All seven token colors meet 4.5:1 contrast on the code background in both themes.

Validation: clippy with warnings denied passes. The scanner tests check that runs always concatenate back to the source, including unterminated and non-ASCII input. Projection tests cover identity versus projected HTML, uncolored fences, and the size-limit fallback. The startup test upgrades a site published under each frozen frontend. An upgrade rehearsal against a site published by the released 0.1.6 binary runs before release.

Public pages and previews now color comments, strings, numbers,
keywords, types, functions, and attributes in fenced code, for Rust and
thirteen other languages, in light and dark themes and without
JavaScript.

Coloring is presentation only. An article's identity HTML, and so its
approved revision, is unchanged: token classes are added when a page is
projected, within the room the plain page leaves under the size limit.

The stylesheet gains the token colors, so the frontend bundle changes.
The frontend of releases 0.1.1 through 0.1.6 is frozen beside 0.1.0's,
and startup verifies a retained site against either before upgrading
its presentation.
@tee8z
tee8z force-pushed the feat/code-highlighting branch from 25aeee9 to 19e6690 Compare October 3, 2026 19:45
@tee8z
tee8z marked this pull request as ready for review October 3, 2026 19:46
@tee8z
tee8z merged commit c273b0e into master Oct 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant