Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Re-Highlight is a powerful syntax highlighter for any text.

License

NotificationsYou must be signed in to change notification settings

reqable/re-highlight

Repository files navigation

latest version

中文版本

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.

art

Getting Started

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.

Principle and Build

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.

  • Installgulp.
npm install gulp -g
  • Synchighlightjs modules.
git submodule update --remote --init
  • Auto generated rule files.
cd toolnpm installgulp generate
  • Run unit-tests.
flutter test

The 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.

Used By

  • re-editor A powerful lightweight text and code editor widget.

Issues and Features

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.

Sponsor

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

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2026 Movatter.jp