Repository navigation
feat!: val_highlight 1.0.0 — stable API, linear-time grammars, docs - #4
Merged
Merged
Conversation
Freeze the core API for 1.0 and fix the engine problems an audit found. Breaking (see docs/upgrading.mdx): - HighlightResult.fromBuffers, rawEnds and rawStacks, and ScopeTable's constructor, nameId and push are no longer public. - IncrementalHighlighter.lastRescannedLines is read-only. - BlockRule is an abstract base class. - Operators takes its characters as required and scope by name; Annotation and Preprocessor take sigil and scope by name. - LanguageRegistry takes fallback by name. - Detection.reason is a DetectionReason enum. - languages/c.dart no longer exports the shared C lists. - ValTheme.lookup merges a dotted scope's prefixes, matching the CSS classes (no change for the built-in themes). - matchingBracket defaults to the language's brackets. Fixed: - Quadratic time on long runs of one pattern in 20 languages (80,000 `#` took 49 s in Swift). test/hostile_input_test.dart now checks every language on every punctuation character and the patterns that were slow. - GrammarException on very long delimiters; delimiters over 1,024 characters are plain text. - Unbounded memory from caching one state per distinct heredoc tag or fence; at most 64 are kept per grammar. - LanguageRegistry.add listed a language twice. Docs: upgrade guide, streaming text, platforms and versions, troubleshooting; capture-group and linear-time guidance for grammar authors; US spelling; benchmark numbers from one fresh run. Every new sample is covered by the snippet tests.
6 tasks done
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.
Summary
Prepares
val_highlight(the core) for 1.0.0: freezes the public API, fixes the engine problems found in the pre-release audit, and brings the docs up to release quality. Version bumped to 1.0.0; the Flutter package and example now depend onval_highlight: ^1.0.0.This is step 1 of 2. The
val_highlight_flutter1.0 changes (Material split, widget API cleanup) come in a separate PR, opened after this one merges. Please don't publish yet — both packages go to 1.0.0 together.Breaking changes (all listed with before/after code in
docs/upgrading.mdx)HighlightResult.fromBuffers,rawEnds,rawStacksandScopeTable(),nameId,pushare no longer public. Results can be sent between isolates as they are (newisolate_test.dart).IncrementalHighlighter.lastRescannedLinesis read-only.BlockRuleisabstract base.Operators(chars, {scope}),Annotation({sigil, scope}),Preprocessor({sigil, scope}).LanguageRegistry(languages, {fallback}).Detection.reasonis aDetectionReasonenum.languages/c.dartno longer exportscKeywords,cTypes,cLiterals,cCommonRules(moved tolib/src/languages/c_family.dart).ValTheme.lookupmerges a dotted scope's prefixes, matching the CSS-class output. Checked: no change for any scope in the 8 built-in themes.matchingBracketdefaults to the language'sEditingSyntax.brackets.Fixes
#in Swift: 49 s). About 20 patterns fixed with lookbehinds or bounded scans.test/hostile_input_test.dartchecks every language on every punctuation character, a letter, a digit, whitespace and the formerly slow units; verified it fails when a fix is reverted.GrammarException; over 1,024 characters they are now plain text.LanguageRegistry.addlisted a language twice when added twice.Highlighting is slightly stricter in a few spots to stay linear (Markdown link text without
[, inline HTML tags without<, C++ attributes without[,$name(not a call in C-like languages, capped JS regex literals). All listed in the CHANGELOG.Docs
docs/site.json).performance.mdxand the READMEs.Related issue
None found.
Checklist
just checkpasses (format, analyze, tests on the VM and JavaScript)CHANGELOG.md:val_highlighthas its## 1.0.0entry (the version is bumped here, asscripts/release.shexpects);val_highlight_flutterhas an## UnreleasednoteVerification
just check: 484 VM and 372 JavaScript core tests, 96 Flutter tests and the example test pass; analyzer clean.just sweepover about 20,000 real files (Flutter SDK + pub cache): 0 errors, 0 scanner mismatches, 0 incremental mismatches, 0 slow files. Its 2 unclosed-region flags also appear onmain.gpt_markdownagainst this core: analyzer clean, same 2042 passing tests as with published 0.1.1. Its 9 failing RTL tests fail identically on 0.1.1 (Flutter 3.50), so they are unrelated.Benchmarks
just bench-languages, Apple M5, Flutter 3.44.2: 43.0 MB/s before, 42.2–43.4 MB/s after (run-to-run noise).just bench: 9,600 lines in 14.4 ms; one keystroke 0.4 ms.