Skip to content
pubscout

re_highlight

0.0.3, released 3 years ago by reqable.com

Powerful text syntax highlighting library translated from highlightjs.

WASM-readySingle maintainer
$ flutter pub add re_highlight
Source repository

What it does

Re-Highlight is a text syntax highlighting library that highlights code and text by defining syntax files. It has built-in rules for dozens of programming languages and converts highlight results to TextSpans.

AI-written summary of version 0.0.3, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need syntax highlighting for code or text within a Flutter application.
  • You want built-in support for multiple programming language highlighting rules.
  • You are building a text editor or code viewing widget.

Skip it when

  • You need an alternative highlight package that is currently active and differs from highlight.dart forks.

Strengths

  • Synchronized with highlightjs v11.9.0
  • Supports dozens of programming languages out of the box
  • Easy to convert results to TextSpan for Text widgets or TextEditingController

Weaknesses

  • Relies on manual synchronization with the highlightjs project for new languages

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
2

Not documented

final Highlight highlight = Highlight();
highlight.registerLanguages(builtinAllLanguages);
const languages = ['json', 'python'];
final HighlightResult result = highlight.highlightAuto('Your text or code', languages);
final TextStyle defaultStyle = TextStyle();
final Map<String, TextStyle> yourTheme = rainbowTheme;
final TextSpanRenderer renderer = TextSpanRenderer(defaultStyle, yourTheme);
result.render(renderer);
final TextSpan? span = renderer.span;

Alternatives

Packages that do the same job and could replace re_highlight.

  • flutter_md

    Fast Markdown parser and canvas renderer for Flutter with text selection and streaming.

  • val_highlight_flutter

    Flutter widgets for displaying and editing syntax-highlighted code.

  • shimmer

    Paints a moving highlight over skeleton placeholders and call-to-action text.

  • code_editor

    A Flutter code editor widget with syntax highlighting, custom themes, and file navigation.

Works with

Packages commonly used together with re_highlight: ones it builds on, ones built on it, and its own family.