सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
val_highlight एक शुद्ध Dart पैकेज है जो 55 भाषाओं के लिए सिंटैक्स हाइलाइटिंग प्रदान करता है, जिसमें इंक्रीमेंटल अपडेट्स, कस्टमाइज़ किए गए थीम और VS Code थीम के आयात का समर्थन है। यह HTML आउटपुट उत्पन्न करता है और Android, iOS, Linux, macOS, Web और Windows जैसे सभी मुख्य प्लेटफॉर्मों पर बिना किसी बाहरी निर्भरता के चलता है। वास्तविक समय में भाषा-विशिष्ट हाइलाइटिंग की आवश्यकता वाले कोड एडिटर या डॉक्यूमेंटेशन टूल बनाने वाले डेवलपर्स के लिए उपयुक्त है।
उपयोग
कोड संपादक कार्यान्वयन
दस्तावेज़ उत्पादन
वास्तविक समय व्याकरण पूर्वावलोकन
शैक्षिक कोडिंग ऐप्स
हाइलाइट कोड के साथ स्टैटिक साइट जनरेशन
क्रॉस-प्लेटफॉर्म कोड प्रदर्शन
मुख्य विशेषताएँ
55 प्रोग्रामिंग भाषाओं का समर्थन करता है
आवधिक उज्ज्वल अपडेट
VS Code थीम आयात क्षमता
HTML आउटपुट उत्पादन
शुद्ध डार्ट कार्यान्वयन
बहुपлатफॉर्म संगतता
इनके लिए उपयुक्त
कोड संपादक बना रहे विकासकर्ता
गतिशील सिंटैक्स हाइलाइटिंग की आवश्यकता वाले ऐप्स
कोड स्निपेट के साथ वेब और मोबाइल ऐप्स
दस्तावेज़ और पाठ्यक्रम प्लेटफॉर्म
हल्के वाक्यांश उज्ज्वलता की आवश्यकता वाले परियोजनाएँ
विचार योग्य बातें
बहुत बड़ी कोड फ़ाइलों के लिए अनुकूलन की आवश्यकता हो सकती है
थीम कस्टमाइजेशन के लिए CSS/JSON प्रारूपों की समझ आवश्यक है
पूर्वनिर्धारित भाषा व्याकरण पर सीमित
कोई निर्मित लाइन संख्या नहीं
प्रदर्शन अपडेट अंतराल पर निर्भर करता है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
val_highlight
Syntax highlighting for Dart and Flutter.
A pure-Dart engine with 55 languages, incremental updates and themes,
plus Flutter widgets to show and edit code.
The engine, in pure Dart: 55 languages plus a generic fallback, flat tokens, incremental updates, language detection, 8 themes, VS Code theme import and HTML output. Runs on the VM, in Flutter and on the web.
Flutter widgets: CodeView to show code, CodeField to edit it, HighlightTextController, and CodeTheme for app-wide defaults.
A val_highlight_jaspr package is planned, built on the same engine.
// FlutterCodeView(source, language: dartLanguage)
// Pure Dartfinal html = constHighlighter().toHtml(source, language: dartLanguage);
CodeView Line numbers, highlighted lines, selection.
Themes Eight built in, or import a VS Code theme.
Languages inside languages Markdown fences, HTML with CSS and JavaScript.
CodeField An editor that highlights as you type.
⚡ Performance
just bench compiles to native code, highlights a Dart file and renders it
to HTML (best of 5 runs, on a MacBook):
Lines
Highlight + HTML
600
1.5 ms
2,400
4.3 ms
9,600
13.9 ms
just bench-languages measures about 256 KB of realistic source per
language on native code. It averages about 43 MB/s, from 30 MB/s (HTML) to
64 MB/s (Markdown). just bench-js runs the same test compiled to
JavaScript, where it averages about 62 MB/s.
With incremental highlighting, one keystroke in the 9,600-line file takes
about 0.4 ms. Frame timings for scrolling and typing in Flutter are in the
val_highlight_flutter README
(just bench-frames).
How it works
One pass, no copying. The scanner walks the source by offset, never
copies it, and time grows in step with input size.
First-character dispatch. Each rule's pattern is analysed once to find
the characters it can start with. The scanner skips positions where no
rule can start, and tries only the rules that can. Rules anchored with ^
are tried only at line starts. States with a rule that can start almost
anywhere fall back to one combined regular expression. Both paths give
identical results, and fuzz tests check this.
Plain-Dart matchers. On native platforms, most patterns run as small
Dart matchers instead of the regular expression engine, with identical
results (checked by fuzz tests). Browsers compile regular expressions to
machine code, so the web keeps using them.
Flat output. Tokens are two integer lists, not a tree of objects.
🛠️ Development
This repository is a pub workspace.
The Flutter version is pinned in .fvmrc (3.44.2), and the justfile runs
everything through FVM:
just setup # install the pinned SDK and fetch dependencies
just check # format check, analyze, all tests (VM and JS)
just devices # list available devices
just example-flutter # run the Flutter example; asks which device to use
just example-web # run the Flutter example in Chrome
just example-dart # run the pure-Dart example
just bench # benchmark
Run just with no arguments to list every command.
Note: with Xcode 27, Flutter 3.44.2 (the pinned version) fails to build
for iOS, and to build macOS apps in profile or release mode, such as the
frame benchmark. Its architecture check rejects Xcode 27's lipo output.
Flutter 3.47 builds both. Web, Android and macOS debug builds work with the
pin.
Built by Val
val_highlight is part of Val, the live visual layer
for AI agents.
💬 Community
Issues and pull requests are welcome. See CONTRIBUTING.md
for setup, tests and what we look for in a pull request.