Skip to content

Change code block highlighting from Prism to Arborium#576

Merged
7w1 merged 24 commits intodevfrom
hazre/feat/arborium-migration
Mar 30, 2026
Merged

Change code block highlighting from Prism to Arborium#576
7w1 merged 24 commits intodevfrom
hazre/feat/arborium-migration

Conversation

@hazre
Copy link
Copy Markdown
Member

@hazre hazre commented Mar 28, 2026

Description

I was inspired by this tweet. https://fxtwitter.com/DiscordPreviews/status/2036671398265995336

  • replace Prism-based code block highlighting with Arborium for timeline code blocks and text previews
  • add Arborium theme metadata, runtime wiring, and a code block theme setting that matches the existing System Theme pattern, with system light/dark selections plus a single manual override
  • extract a reusable SettingMenuSelector, remove NotificationModeSwitcher, and reuse the shared selector in notification, room, and theme settings
  • wrap rendered code blocks so long lines break in both highlighted messages and text previews instead of forcing wide horizontal overflow

The cool thing about Arborium is that all the language support and themes are loaded from a CDN. So you basically ship nothing and on demand, it downloads the proper grammer for each language that shows up in the messages. fallback is just no syntax highlighting.

Sceenshots

Recording.2026-03-28.224825-00.00.00.000-00.00.17.936.mp4
image

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

AI disclosure:

  • Partially AI assisted (clarify which code was AI assisted and briefly explain what it does).
  • Fully AI generated (explain what all the generated code does in moderate detail).

The main change in this PR is replacing the old Prism-based highlighting path with Arborium for rendered message code blocks and text previews. The message renderer and text viewer now go through the Arborium-backed code highlight renderer, Arborium themes are loaded through the new theme bridge instead of the old Prism theme classes, and unsupported or failed language/theme loads still fall back safely to plain rendered code. The settings work in this PR now exposes code block theming with the same structure as the existing app theme controls: a System Theme toggle that keeps separate light and dark Arborium theme selections, plus a single Manual Theme selector that can override them when system mode is off. The reusable SettingMenuSelector extraction is supporting cleanup that lets the same dropdown pattern drive notification settings, room notification controls, and the theme pickers while removing the older one-off switcher component. The wrapping changes are the last part of that migration work: Arborium-rendered code now wraps in both timeline messages and text previews so long lines stay readable without forcing wide overflow. The tests cover Arborium theme selection and loading, selector reuse, notification option reuse, and the message/text-viewer code block regressions.

@hazre hazre changed the title feat: add reusable settings selectors and code block themes feat: migrate code block highlighting from Prism to Arborium Mar 28, 2026
@hazre hazre changed the title feat: migrate code block highlighting from Prism to Arborium Change code block highlighting from Prism to Arborium Mar 28, 2026
@hazre hazre force-pushed the hazre/feat/arborium-migration branch from 5a30404 to 0f7a28b Compare March 28, 2026 21:36
@hazre
Copy link
Copy Markdown
Member Author

hazre commented Mar 28, 2026

Okay I added a better theme selector as well. I think this is ready to go.
image

@hazre hazre marked this pull request as ready for review March 28, 2026 21:38
@hazre hazre requested a review from 7w1 as a code owner March 28, 2026 21:38
@7w1
Copy link
Copy Markdown
Member

7w1 commented Mar 30, 2026

merge conflicts D:

@hazre
Copy link
Copy Markdown
Member Author

hazre commented Mar 30, 2026

Yeah my own PR is bringing me pain

…borium-migration

# Conflicts:
#	src/app/plugins/react-custom-html-parser.test.tsx
#	src/app/plugins/react-custom-html-parser.tsx
#	src/app/utils/sanitize.test.ts
#	src/app/utils/sanitize.ts
@github-actions
Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

Status Preview URL Commit Alias Updated (UTC)
✅ Deployment successful! https://pr-576-sable.raspy-dream-bb1d.workers.dev 3bb692f pr-576 Mon, 30 Mar 2026 21:32:29 GMT

Copy link
Copy Markdown
Member

@7w1 7w1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm. appears to function properly and styles are consistent

@7w1 7w1 added this pull request to the merge queue Mar 30, 2026
Merged via the queue into dev with commit 82f9c8d Mar 30, 2026
12 checks passed
@hazre hazre deleted the hazre/feat/arborium-migration branch March 31, 2026 12:15
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.

2 participants