💄✨:highlight code where it is built - #1898
Conversation
✅ Deploy Preview for gh-pages-openinf ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (1)
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. 📝 WalkthroughWalkthroughThe change adds Prism syntax highlighting for Markdown code blocks and Sass styles for highlighted tokens. It supports selected grammars, maps ChangesCode highlighting
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
Merge Risk: ⚪ Minimal · up to The Prism highlighting configuration change is ready to merge after normal checks. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
d55b28b to
dd3ca60
Compare
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
dd3ca60 to
388e425
Compare
Summary
Every fenced code block on the site rendered as flat text. There was no highlighter registered with markdown-it, no
prismjsorhighlight.jsorshikiin 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
sanitizeSdkHtmlbefore the layout embeds it, and its attribute allowlist isid,class,title,aria-label,aria-describedby. Nostyle. 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 theisStringpage after sanitisation.Flags
Grammars are loaded by name rather than wholesale.
ts,js,shandshellall reach theirs through Prism's own aliases, so no flag in use needed changing.consoleis the exception. Prism has no such language; a prompt with its output isshell-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.
textwants 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
$secondaryrather than on parchment, so each was measured against that.#dae5e7The first pass had comment at 3.95 and punctuation at 4.44; both were darkened until they cleared 4.5.
Validation
nps buildthennps test— every verify task passesconsoleblock, which highlights as a sessionNote
This does not change any info string. A separate question about the flag convention in
OpenINF/sdkis still open, and nothing here depends on how it is settled.🤖 Generated with Claude Code
Summary by CodeRabbit