Skip to content

feat: inline code and highlighted code blocks in commits - #124

Merged
mnapoli merged 1 commit into
productionfrom
feat/code-highlighting
Oct 15, 2026
Merged

mnapoli merged 1 commit into
productionfrom
feat/code-highlighting

Conversation

@mnapoli

@mnapoli mnapoli commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Commits and replies now render inline code and fenced code blocks. Blocks are syntax highlighted on the server with tempest/highlight.

Run `composer install`, then:
```php
$name = 'devnull';
```

How it works

  • Splitting and highlighting: the CodeSpans service splits a body into prose and code. A block is a line starting with or more backticks, an optional language, and a closing line of or more; inline code is a single-line `…`. Unclosed code stays plain text. CodeSpans::highlight() turns the body into text, inline-code and block segments. Commits now carry these as body_segments, added in Commit::toArray(). The service is #[Scoped], so a page of commits shares one highlighter.
  • Rendering: a new CommitBody component replaces the body paragraph in the commit card and thread replies. Only blocks inject HTML, and the highlighter escapes the code first. Text segments still go through LinkifiedText and emojify.
  • Theme: the .hl-* classes in app.css use the app's own colours (primary, lanes, muted), so light and dark mode both work.

Languages

Only languages tempest/highlight supports get colours: PHP, JS/TS, Python, Bash, SQL, CSS/SCSS, HTML, JSON, YAML, Blade, Twig, Vue, Svelte, Diff and more. The language name is case-insensitive. A block without a language, or with one tempest doesn't know, shows as escaped plain code; there is no auto-detection or fallback. Blocks show the language label as written.

Code is left alone

  • Emoji shortcodes (:fire) are not replaced inside code, both when the commit is saved and in the composer while typing.
  • URLs in code don't trigger link previews, and @mentions in code (@Override, @param) don't notify anyone.

Not changed

The OG image, meta description, notifications, flash toast and "who to follow" suggestions still show the raw body.

@mnapoli
mnapoli force-pushed the feat/code-highlighting branch from 767ce75 to e93f729 Compare October 15, 2026 18:01
Commits and replies now render `inline code` and fenced code blocks,
highlighted server-side with tempest/highlight. Blocks are highlighted
when they name a supported language; other blocks render as escaped
plain code. Emoji shortcodes, link previews and mentions skip code.
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