feat(highlight): user-supplied sublime-syntax via syntaxes/ next to the deck#122
Merged
Conversation
…he deck Introduce a Highlighter newtype that owns the syntect SyntaxSet, threaded through parse_markdown and render_deck. Delete the OnceLock global and the free validate_language / highlight_html functions so no caller can look up a language token against an unconfigured default set. Highlighter::with_user_dir(dir) augments the built-in set with any *.sublime-syntax files under dir; malformed files are line-numbered BuildErrors (silent drop forbidden). The CLI discovers syntaxes/ next to the deck by convention, mirroring layouts/ and css/, and --watch rebuilds on .sublime-syntax changes. Closes #116 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #116
Summary
peitho_core::highlight::Highlighter— a newtype owningsyntect::parsing::SyntaxSet, threaded throughparse_markdownandrender_deckas&Highlighter. The oldOnceLock<SyntaxSet>global and the freevalidate_language/highlight_htmlare deleted; no free function onhighlight::takes a language token without a&Highlighteranymore, so the "default set only" path is unrepresentable at the API surface.Highlighter::with_user_dir(dir)augments the built-in set with*.sublime-syntaxfiles underdir. A malformed file becomes a line-numberedBuildError(silent drop forbidden). An emptysyntaxes/behaves like defaults.syntaxes/next to the deck by convention (same shape aslayouts//css/) — no CLI flag added, per author decision.peitho build --watchrebuilds on.sublime-syntaxchanges.Three lenses
.crn, TypeScript, custom repo languages) gains highlighting without peitho having to know about it. Also unblocks a workable answer for Unknown-language help text suggests 'ts', but syntect's default set has no TypeScript #105 (TypeScript missing from defaults): drop a TS.sublime-syntaxinsyntaxes/.Highlighteris the only way to reachfind_syntax_by_token. A caller cannot forget user syntaxes; the type requires an instance..crnblock was rejected before was not "Carina is missing" (symptom) but "the syntax set is baked in at process init with no injection point" (root). The one upstream fix threads aHighlighterthrough the pipeline.All three lenses agreed unambiguously, so this shape was chosen without ambiguity.
What is NOT in this PR (by explicit plan decision)
--syntaxes) — convention-only per author.Test plan
cargo test --workspace(x3)cargo clippy --workspace --all-targets -- -D warningscargo fmt --all --checkgit diff --exit-code bindings/cd packages/peitho-present && npm run build && npm test && npm run typecheckgit diff --exit-code packages/peitho-present/dist/shell.jsbuild_artifacts_uses_syntaxes_dir_next_to_the_deck— a deck with a```carinablock plussyntaxes/carina.sublime-syntaxnext to it builds and produceshl-*spans.user_dir_validates_carina_and_defaults_reject_it— samecarinatoken is a build error underHighlighter::defaults().Design record:
docs/plans/2026-07-05-user-syntaxes.md.🤖 Generated with Claude Code