Skip to content

💄✨:highlight code where it is built - #1898

Merged
openinf-commit-queue[bot] merged 1 commit into
livefrom
infra/syntax-highlighting
Sep 13, 2026
Merged

openinf-commit-queue[bot] merged 1 commit into
livefrom
infra/syntax-highlighting

Conversation

@DerekNonGeneric

@DerekNonGeneric DerekNonGeneric commented Sep 12, 2026

Copy link
Copy Markdown
Member

Summary

Every fenced code block on the site rendered as flat text. There was no highlighter registered with markdown-it, no prismjs or highlight.js or shiki in the tree, and no token colours in any stylesheet. A TypeScript example and a shell command read the same as prose in a box.

Prism now runs once, at build time. The page is static by the time anyone asks for it, so shipping a highlighter to mark it up again in the browser would be the same work done twice and later.

Class-based, and that is not a preference

The SDK reference passes through sanitizeSdkHtml before the layout embeds it, and its attribute allowlist is id, class, title, aria-label, aria-describedby. No style. Shiki colours by inline style unless configured otherwise, so its output would have been stripped from exactly the pages this was asked for. Prism emits <span class="token …">, which survives. Verified: 38 token spans on the isString page after sanitisation.

Flags

Grammars are loaded by name rather than wholesale. ts, js, sh and shell all reach theirs through Prism's own aliases, so no flag in use needed changing.

console is the exception. Prism has no such language; a prompt with its output is shell-session, so it is mapped. That is the flag the portal's own pages use most, 13 of them.

A flag with no grammar highlights nothing rather than failing. text wants that, and so does the generated SDK corpus, which carries flags from declarations this repository does not write.

Colours

The site's own palette, shaded for contrast, rather than a theme borrowed from elsewhere: warm red for reserved words, teal for literals, muted ink for punctuation. Code sits on $secondary rather than on parchment, so each was measured against that.

Token Contrast on #dae5e7
string 4.91:1
keyword 6.05:1
comment 6.09:1
punctuation 6.49:1
function, class name 8.10:1

The first pass had comment at 3.95 and punctuation at 4.44; both were darkened until they cleared 4.5.

Validation

  • nps build then nps test — every verify task passes
  • HTML validation clean over the whole site, Prism's markup included
  • checked on a portal handbook page, on an API symbol page, and on a console block, which highlights as a session

Note

This does not change any info string. A separate question about the flag convention in OpenINF/sdk is still open, and nothing here depends on how it is settled.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added syntax highlighting for fenced code blocks in documentation.
    • Supports common programming languages, TypeScript, shell sessions, comments, keywords, literals, and command output.
    • Added distinct styling for inserted and deleted code.
    • Unknown code languages remain displayed without forced highlighting.
  • Style
    • Applied a theme-aligned color palette to code examples for improved readability and visual consistency across the site.

@netlify

netlify Bot commented Sep 12, 2026

Copy link
Copy Markdown

Deploy Preview for gh-pages-openinf ready!

Name Link
🔨 Latest commit 388e425
🔍 Latest deploy log https://app.netlify.com/projects/gh-pages-openinf/deploys/6aa5ede992e31d0008be152b
😎 Deploy Preview https://deploy-preview-1898--gh-pages-openinf.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: 1da0f5fc-ffee-405e-a1f9-8a983f7a0d19

📥 Commits

Reviewing files that changed from the base of the PR and between d55b28b and dd3ca60.

📒 Files selected for processing (1)
  • eleventy.config.mjs

Included review availability: 4 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


📝 Walkthrough

Walkthrough

The change adds Prism syntax highlighting for Markdown code blocks and Sass styles for highlighted tokens. It supports selected grammars, maps console to shell-session, preserves unknown languages, adds TypeScript fence validation, and updates project terms.

Changes

Code highlighting

Layer / File(s) Summary
Prism highlighting pipeline
package.json, eleventy.config.mjs, .remarkrc.mjs, project-terms.txt
Adds Prism packages and configures Markdown highlighting with grammar loading, the console alias, fallback handling, updated project terms, and ts fence validation.
Theme token styling
_assets/styles/_code.scss, _assets/styles/main.scss
Adds theme-derived styles for Prism tokens, shell output, prompts, deleted tokens, and inserted tokens. Imports the new stylesheet.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Markdown
  participant MarkdownIt as markdown-it
  participant Prism
  participant Theme as Sass theme
  Markdown->>MarkdownIt: Render fenced code block
  MarkdownIt->>Prism: Highlight supported language
  Prism-->>MarkdownIt: Return highlighted HTML
  MarkdownIt-->>Theme: Emit token classes
  Theme-->>Markdown: Apply themed code styles
Loading

Merge Risk: ⚪ Minimal · up to 388e4

The Prism highlighting configuration change is ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: build-time code highlighting. The emojis add noise, but the title remains specific and related to the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch infra/syntax-highlighting

Comment @coderabbitai help to get the list of available commands.

@socket-security

socket-security Bot commented Sep 12, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​types/​prismjs@​1.26.61001007381100
Addedprismjs@​1.30.01001008991100

View full report

Every fenced block on the site rendered as flat text. There was no
highlighter registered with markdown-it and no token colors in the
stylesheet, so a TypeScript example and a shell command read the same
as prose in a box.

Prism runs once, at build time. A page is static by the time anyone
asks for it, and shipping a highlighter to mark it up again in the
browser would be the same work done twice and later.

Class-based, not inline styles, and that is not a preference. The SDK
reference passes through the sanitizer before the layout embeds it,
and its attribute allowlist has `class` but no `style`, so a
highlighter that colors by attribute would have its work stripped from
exactly those pages.

Grammars are loaded by name rather than wholesale, and `ts`, `js`,
`sh` and `shell` reach theirs through Prism's own aliases. `console`
is the one the site uses that Prism does not know: a prompt with its
output is `shell-session` there, so it is mapped. A flag with no
grammar highlights nothing rather than failing, which is what `text`
wants and what the generated corpus needs, since that carries flags
from declarations this repository does not write.

Flags are looked up in a map rather than on `Prism.languages` itself,
because that object answers for its prototype as readily as for its
grammars: a block flagged `constructor` finds `Object`'s and hands it
to the tokenizer as though it were a grammar.

The token colors are the site's palette shaded for contrast, not a
theme borrowed from elsewhere: warm red for reserved words, teal for
literals, muted ink for punctuation. Code sits on $secondary rather
than on parchment, so each was measured against that. The lowest is
4.91:1 and the rest are above 6.

`ts` joins the info string allowlist. The SDK settles on it as the one
flag for TypeScript, and a page written here that borrows an example
from there should not have to spell it the longer way to pass lint.

Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is>
Assisted-by: Claude-Code:claude-opus-5
@DerekNonGeneric
DerekNonGeneric force-pushed the infra/syntax-highlighting branch from dd3ca60 to 388e425 Compare September 13, 2026 00:27
@DerekNonGeneric DerekNonGeneric added the 🚀 Status: Commit Queue Land this pull request when its checks pass label Sep 13, 2026
@openinf-commit-queue
openinf-commit-queue Bot merged commit 7aad616 into live Sep 13, 2026
17 checks passed
@openinf-commit-queue openinf-commit-queue Bot removed the 🚀 Status: Commit Queue Land this pull request when its checks pass label Sep 13, 2026
@openinf-commit-queue
openinf-commit-queue Bot deleted the infra/syntax-highlighting branch September 13, 2026 18:57
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