패키지, 저장소 및 앱 카테고리 검색

re_highlight 표지
패키지 상세v0.0.3

re_highlight

Re-Highlight는 강력한 텍스트 구문 강조 라이브러리입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
15.4만
좋아요
24
Pub 점수
140

패키지 설치

flutter pub add re_highlight

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Re-Highlight는 모든 주요 플랫폼에서 여러 프로그래밍 언어를 지원하는 강력한 Flutter 라이브러리로, 텍스트의 구문 강조를 위해 설계되었습니다. 개발자들이 코드를 정확한 색상 및 서식으로 렌더링할 수 있게 하여 코드 에디터, 문서 표시 또는 교육 앱에서 가독성을 향상시킵니다. 성능과 사용자 맞춤 설정을 고려하여 제작되었으며, 간단한 패키지 추가만으로 Flutter 프로젝트에 원활하게 통합됩니다. 효율적인 파싱 기술을 활용하고 동적 테마 업데이트를 지원하여 실시간 코드 렌더링에 이상적입니다.

사용 사례

  • 코드 편집기 위젯
  • 문서 뷰어
  • 교육용 코딩 앱
  • 라이브 코드 미리보기
  • 구문 인식 텍스트 표시

주요 기능

  • 다국어 지원
  • 사용자 정의 테마
  • 실시간 강조
  • 크로스 플랫폼 호환성
  • 경량 파싱 엔진
  • 동적 테마 전환

적합한 대상

  • 코드 편집기 개발 중인 개발자
  • 구문 인식 텍스트 렌더링이 필요한 앱
  • 코드 예제가 포함된 교육 도구
  • 문서 인터페이스

고려 사항

  • 매우 큰 코드 블록에 대해 조정이 필요할 수 있습니다
  • 제한된 내장 언어 감지
  • 테마 사용자 정의는 수동 구성이 필요합니다
  • 성능은 텍스트 크기와 복잡도에 따라 달라집니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Re-Highlight

latest version

中文版本

Re-Highlight is a powerful syntax highlighter, which is a sub-module of the Reqable project. Re-Highlight can highlight a text by simply defining a syntax file. And Re-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 of Re-Highlight is all written in the Dart, translated from the highlightjs project. The implementation idea and inspiration of Re-Highlight come from the highlight.dart project. We are grateful for these great open-source projects. Due to some issues with the highlight.dart project and its discontinuation, this project was born.

👏👏👏 Re-Highlight has been synchronized with the latest version v11.9.0 of highlightjs 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 in pubspec.yaml.

dependencies:
  re_highlight: ^0.0.3

Highlight yout text or code.

final Highlight highlight = Highlight();
highlight.registerLanguages(builtinAllLanguages);

const languages = [
  'json',
  'python',
  // other language
];

// Highlight your text or code.
final HighlightResult result = _highlight.highlightAuto('Your text or code', languages);

// Define your styles.
final TextStyle defaultStyle = TextStyle();
final Map<String, TextStyle> yourTheme = rainbowTheme;

// Convert highlight result to TextSpan
final TextSpanRenderer renderer = TextSpanRenderer(defaultStyle, yourTheme);
result.render(renderer);
final TextSpan? span = renderer.span;

// Pass the span to your Text Widget or TextEditingController.

More codes please see example.

Principle and Build

The Re-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 the src directory, the syntax highlighting rule files are located in the lib\languages directory, and the theme style files are located in the lib\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 highlightjs modules.
git submodule update --remote --init
  • Auto generated rule files.
cd tool
npm install
gulp generate
  • Run unit-tests.
flutter test

The code in the syntax highlighting rule interpreter part is translated directly from highlightjs, 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 of Re-Highlight are strictly translated from the highlightjs project. If you find any syntax issues or need support for new languages, we suggest submitting them to highlightjs, and we will try to synchronize them as soon as possible.

If it's related to Dart or Flutter, it is welcome to submit an issue or PR in this project.

Sponsor

If you would like to sponsor this project, please consider sponsoring the highlightjs project first. If you still have the capacity, you can support us by purchasing a Reqable license.

카테고리

의존성

의존성 목록 2 개

소스 저장소

이 패키지를 사용하는 프로젝트

순위