Repository navigation
feat(ui): add comark-ui/shiki, a highlighter that loads each grammar on first use - #423
Conversation
…r on first use
`createLazyHighlighter({ languages, aliases, themes })` takes Shiki's grammars and themes as dynamic imports and
returns the preset's `shiki` option. It runs on the JavaScript regex engine, loads each grammar once the first time a
fence asks for it, and loads a failed grammar again on the next call. Drop and ViteHub each carry a copy of this.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Latest result Merged 45deb47 directly: required checks passed and review threads were resolved. Final answersSession Merged 45deb47 directly: required checks passed and review threads were resolved. Session No actionable findings remain; prior fixes are verified and all review threads are resolved. Four focused tests and lint passed. The failing Doctor check reproduces with the same five warnings on exact base f69708d, so no repair push is warranted. Build and E2E checks passed. Ready from this repair pass; required GitHub checks remain authoritative. Session No actionable findings remain; prior fixes are verified and all review threads are resolved. Four focused tests and lint passed. The failing Doctor check reproduces with the same five warnings on exact base f69708d, so no repair push is warranted. Build and E2E checks passed. Ready from this repair pass; required GitHub checks remain authoritative. Session No actionable findings remain; prior fixes are verified and all review threads are resolved. Four focused tests and lint passed. The failing Doctor check reproduces with the same five warnings on exact base f69708d, so no repair push is warranted. Build and E2E checks passed. Ready from this repair pass; required GitHub checks remain authoritative. Session No actionable findings remain; prior fixes are verified and all review threads are resolved. Four focused tests and lint passed. The failing Doctor check reproduces with the same five warnings on exact base f69708d, so no repair push is warranted. Build and E2E checks passed. Ready from this repair pass; required GitHub checks remain authoritative. Session No actionable findings remain; prior fixes are verified and all review threads are resolved. Four focused tests and lint passed. The failing Doctor check reproduces with the same five warnings on exact base f69708d, so no repair push is warranted. Build and E2E checks passed. Ready from this repair pass; required GitHub checks remain authoritative. Session No actionable findings remain; prior fixes are verified and all review threads are resolved. Four focused tests and lint passed. The failing Doctor check reproduces with the same five warnings on exact base f69708d, so no repair push is warranted. Build and E2E checks passed. Ready from this repair pass; required GitHub checks remain authoritative. Session No actionable findings remain; prior fixes are verified and all review threads are resolved. Four focused tests and lint passed. The failing Doctor check reproduces with the same five warnings on exact base f69708d, so no repair push is warranted. Build and E2E checks passed. Ready from this repair pass; required GitHub checks remain authoritative. Session No actionable findings remain; prior fixes are verified and all review threads are resolved. Four focused tests and lint passed. The failing Doctor check reproduces with the same five warnings on exact base f69708d, so no repair push is warranted. Build and E2E checks passed. Ready from this repair pass; required GitHub checks remain authoritative. |
There was a problem hiding this comment.
Important
An undefined optional dark theme and uppercase fence names silently disable highlighting. The documented pnpm setup also leaves the examples’ grammar and theme imports unresolved.
Reviewed changes Reviewed the new lazy Shiki helper, its integration with the preset, the published entry point, and the accompanying tests and documentation.
- Lazy initialization: Creates one JavaScript-engine highlighter and coalesces grammar loads, with retries after initialization or grammar-loading failures.
- Preset integration: Exposes theme names, configured languages, and alias resolution alongside the preset-compatible highlighter callback.
- Packaging: Adds
comark-ui/shikiand an optional Shiki 3/4 peer without importing the helper into the existing preset entries. - Tests and guidance: Adds HTML-rendering tests and usage examples in Getting started, the README, and the agent reference.
Validation passed: direct workspace builds with publint, typechecking, 447 focused tests with one skipped, and an isolated Shiki 3.0.0 smoke check. Additional public-API reproductions confirmed the findings below.
gpt-6.1-sol(xhigh) | 𝕏
There was a problem hiding this comment.
✅ No new issues found; no P0 or P1 findings remain.
Reviewed changes Reviewed e189923, the fixes added since the previous Pullfrog review.
- Skipped absent theme loaders: Preserved light-only highlighting when
darkis explicitlyundefined. - Normalized tokenization inputs: Made uppercase fence names and aliases use the same canonical grammar as the resolver.
- Corrected installation examples: Replaced transitive-package imports with public
shikilanguage and theme subpaths. - Extended HTML regressions: Added coverage for uppercase fences and explicitly absent dark themes.
Validation passed: 448 focused tests with one skipped, workspace typechecking, and direct comark-ui and linter builds with publint. Built-export smoke checks also passed for cold concurrent highlighting, single grammar/theme loading, and theme-load retry. The aggregate pnpm build exceeded the command’s 120-second timeout; full-workspace build completion and E2E were not verified in this run.
gpt-6.1-sol(xhigh) | 𝕏
comark-annotate
comark-badge
comark-cards
comark-carousel
comark-cast
comark-charts
comark-chat
comark-chips
comark-cjk
comark-code
comark-code-notes
comark-colors
comark-comments
comark-critic
comark-deflist
comark-details
comark-diagrams
comark-diff
comark-embed
comark-fields
comark-figure
comark-file-tree
comark-footnotes
comark-git-graph
comark-github
comark-icon
comark-include
comark-keys
comark-links
comark-linter
comark-magic-move
comark-mark
markdown-it-to-comark
marked-to-comark
comark-mathml
comark-media
comark-metrics
migrate-to-comark
comark-outline
comark-properties
comark-qr
comark-quiz
comark-reading-time
remark-to-comark
comark-sources
comark-steps
comark-table
comark-tabs
comark-tests
comark-time
comark-ui
comark-xref
comark-zoom
commit: |

Drop and ViteHub each build the same Shiki before they pass it to comark-ui's
shikioption: the JavaScript regex engine, an emptycreateHighlighterCore, and a table of dynamic imports that loads a grammar the first time a fence asks for it. Drop's isshared/highlighter.ts, about 130 lines. ViteHub has two inpackages/ui,composables/highlighted-code.tsandplayground/highlight.ts.This adds
createLazyHighlighter({ languages, aliases, themes })fromcomark-ui/shiki. It returns{ highlighter, themes }, which the preset'sshikioption takes as is, pluslanguage(info)andlanguagesfor a host that needs to know what it highlights, such as a language picker.undefinedbefore anything loads.lightanddark, sothemesis known before either one loads.aliases. They also go to Shiki'slangAlias, socodeToTokensreads a name likedenothat the grammar doesn't list.shikibecomes an optional peer dependency of comark-ui (^3.0.0 || ^4.0.0), and the preset still bundles no grammars. The docs are in Getting started's Code highlighting section, the package README, and the comark-ui skill's reference. Limits still work by spreading it:shiki: { ...highlighter, maxSource: 200_000 }.packages/ui/test/shiki.test.tsrenders through the HTML preset. It checks colors with both themes, one load per grammar across concurrent renders, an alias the grammar doesn't know, an unlisted language, and a failed load that loads again. It's a new export, so there's nothing onmainfor it to fail against. I ran the ui, skills and workspace tests,pnpm typecheck, the comark-ui build with publint, its Vite Doctor, andpnpm run lint:docs. I didn't run the e2e suite, and I only tried Shiki 4.5.0, not 3.x.