- Notifications
You must be signed in to change notification settings - Fork14
Re-Highlight is a powerful syntax highlighter for any text.
License
reqable/re-highlight
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Re-Highlight is a powerful syntax highlighter, which is a sub-module of theReqable project.Re-Highlight can highlight a text by simply defining a syntax file. AndRe-Highlight has built-in syntax highlighting rules for dozens of programming languages, it is easy to make your text syntax highlighting in just a few lines of code.
The implementation code ofRe-Highlight is all written in theDart, translated from thehighlightjs project. The implementation idea and inspiration ofRe-Highlight come from thehighlight.dart project. We are grateful for these great open-source projects. Due to some issues with thehighlight.dart project and its discontinuation, this project was born.
👏👏👏Re-Highlight has been synchronized with the latest version v11.9.0 ofhighlightjs and has passed all test cases.
The below shows the highlighting effect. For more styles and languages, please refer to example.
Add the followings inpubspec.yaml.
dependencies:re_highlight:^0.0.3
Highlight yout text or code.
finalHighlight highlight=Highlight();highlight.registerLanguages(builtinAllLanguages);const languages= ['json','python',// other language];// Highlight your text or code.finalHighlightResult result= _highlight.highlightAuto('Your text or code', languages);// Define your styles.finalTextStyle defaultStyle=TextStyle();finalMap<String,TextStyle> yourTheme= rainbowTheme;// Convert highlight result to TextSpanfinalTextSpanRenderer renderer=TextSpanRenderer(defaultStyle, yourTheme);result.render(renderer);finalTextSpan? span= renderer.span;// Pass the span to your Text Widget or TextEditingController.
More codes please seeexample.
TheRe-Highlight project is divided into three parts: syntax highlighting rule interpreter, syntax highlighting rule files, and theme style files. The rule interpreter is located in thesrc directory, the syntax highlighting rule files are located in thelib\languages directory, and the theme style files are located in thelib\styles directory. The latter two are automatically generated based on the files in highlightjs and do not require manual modification.
- Install
gulp.
npm install gulp -g- Sync
highlightjsmodules.
git submodule update --remote --init- Auto generated rule files.
cd toolnpm installgulp generate- Run unit-tests.
flutter testThe code in the syntax highlighting rule interpreter part is translated directly fromhighlightjs, and we have tried to keep the consistency of file structure, class names, function names, and code logic as much as possible to facilitate future upgrades and synchronization.
- re-editor A powerful lightweight text and code editor widget.
The syntax and logic ofRe-Highlight are strictly translated from thehighlightjs project. If you find any syntax issues or need support for new languages, we suggest submitting them tohighlightjs, and we will try to synchronize them as soon as possible.
If it's related toDart orFlutter, it is welcome to submit an issue or PR in this project.
If you would like to sponsor this project, please consider sponsoring thehighlightjs project first. If you still have the capacity, you can support us by purchasing aReqable license.
About
Re-Highlight is a powerful syntax highlighter for any text.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
