Skip to content

Highlight C#, shell, PowerShell and HTTP code blocks - #2781

Draft
jernejk wants to merge 2 commits into
SSWConsulting:mainfrom
jernejk:jk/code-highlighting-csharp-shell
Draft

jernejk wants to merge 2 commits into
SSWConsulting:mainfrom
jernejk:jk/code-highlighting-csharp-shell

Conversation

@jernejk

@jernejk jernejk commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Description

✅

  • TinaCMS's rich-text Prism wrapper uses prism-react-renderer, whose bundled language set has no csharp / cs, bash / shell / sh, powershell or http grammars.
  • Hundreds of SSW Rules are tagged with those languages (about 560 with csharp/cs alone) and render monochrome on https://www.ssw.com.au. Example: Aspire — YAML is coloured, C# is not (token plain only).
  • This PR uses prism-react-renderer's documented custom-language approach: assign the vendored Prism to globalThis, then load upstream prismjs/components (prism-csharp, prism-bash, prism-powershell, prism-http) so they register onto that same instance. Aliases: cs/dotnet → csharp, sh/shell → bash.
  • No custom grammars. Dotenv is not covered (PrismJS has no dotenv component; left out of scope).
  • One side-effect import from components/typography-components.tsx. Direct deps: prism-react-renderer@2.4.1, prismjs@1.30.0, @types/prismjs@1.26.6 (lockfile regenerated with pnpm).
  • Unit test: __tests__/lib/prismGrammars.test.ts (csharp/cs/dotnet, bash/sh/shell, powershell, http).

Prepared with AI assistance.

Screenshot (optional)

✅

Captured from the local Jackdaw preview of centralise-local-dev-config-and-secrets-in-apphost with the import removed, then restored.

Before (C# block — 1 computed token colour)

Before: monochrome C#

After (same C# block — 4 computed token colours)

After: highlighted C#

C# source block on that rule Token colours before Token colours after
Client registration 1 4
AppHost 1 6
Web Program.cs 1 5
JSON blocks (control) 3 3 (unchanged)

Full-page before/after (optional): before · after

Verification

  • pnpm exec biome lint on the touched files — pass
  • pnpm exec tsc --noEmit — pass
  • pnpm exec jest __tests__/lib/prismGrammars.test.ts — 4/4 pass

TinaCMS's prism-react-renderer bundle omits csharp/bash/powershell/http/dotenv,
so hundreds of SSW Rules tagged with those languages render monochrome.

Register the missing PrismJS grammars into the shared prism-react-renderer
registry (with cs→csharp and shell→bash aliases) and cover them with a unit test.

Prepared with AI assistance.
Drop the custom dotenv grammar and PowerShell flag tweak. Load csharp,
bash, powershell and http from prismjs/components onto prism-react-renderer's
Prism (documented custom-language approach), with cs/dotnet->csharp and
sh/shell->bash aliases.

Prepared with AI assistance.
@jernejk jernejk changed the title Highlight C#, shell, PowerShell, HTTP and .env code blocks Highlight C#, shell, PowerShell and HTTP code blocks Nov 6, 2026

This branch has not been deployed

No deployments
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