{"id":18936371,"url":"https://github.com/reqable/re-highlight","last_synced_at":"2025-04-13T11:09:25.028Z","repository":{"id":220632224,"uuid":"752161037","full_name":"reqable/re-highlight","owner":"reqable","description":"Re-Highlight is a powerful syntax highlighter for any text.","archived":false,"fork":false,"pushed_at":"2025-03-18T09:10:35.000Z","size":2260,"stargazers_count":63,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T11:09:11.745Z","etag":null,"topics":["dart","flutter","language-grammars","syntax-highlighter","text-highlighting"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/re_highlight","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reqable.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-03T07:49:35.000Z","updated_at":"2025-03-26T08:11:27.000Z","dependencies_parsed_at":"2024-02-05T13:32:46.918Z","dependency_job_id":"f84b6493-8fb7-4178-a046-602ea7ae6f18","html_url":"https://github.com/reqable/re-highlight","commit_stats":null,"previous_names":["reqable/reqable-highlight","reqable/re-highlight"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reqable%2Fre-highlight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reqable%2Fre-highlight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reqable%2Fre-highlight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reqable%2Fre-highlight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reqable","download_url":"https://codeload.github.com/reqable/re-highlight/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248703199,"owners_count":21148118,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","flutter","language-grammars","syntax-highlighter","text-highlighting"],"created_at":"2024-11-08T12:07:11.164Z","updated_at":"2025-04-13T11:09:24.998Z","avatar_url":"https://github.com/reqable.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Re-Highlight\n\n[![latest version](https://img.shields.io/pub/v/re_highlight.svg?color=blue)](https://pub.dev/packages/re_highlight)\n\n[中文版本](./README_CN.md)\n\n`Re-Highlight` is a powerful syntax highlighter, which is a sub-module of the [Reqable](https://reqable.com) 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.\n\nThe implementation code of `Re-Highlight` is all written in the `Dart`, translated from the [highlightjs](https://github.com/highlightjs/highlight.js) project. The implementation idea and inspiration of `Re-Highlight` come from the [highlight.dart](https://github.com/git-touch/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.\n\n👏👏👏 `Re-Highlight` has been synchronized with the latest version v11.9.0 of `highlightjs` and has passed all test cases.\n\nThe below shows the highlighting effect. For more styles and languages, please refer to example.\n\n![art](./arts/art01.png)\n\n## Getting Started\n\nAdd the followings in `pubspec.yaml`.\n\n```yaml\ndependencies:\n  re_highlight: ^0.0.3\n```\n\nHighlight yout text or code.\n\n```dart\nfinal Highlight highlight = Highlight();\nhighlight.registerLanguages(builtinAllLanguages);\n\nconst languages = [\n  'json',\n  'python',\n  // other language\n];\n\n// Highlight your text or code.\nfinal HighlightResult result = _highlight.highlightAuto('Your text or code', languages);\n\n// Define your styles.\nfinal TextStyle defaultStyle = TextStyle();\nfinal Map\u003cString, TextStyle\u003e yourTheme = rainbowTheme;\n\n// Convert highlight result to TextSpan\nfinal TextSpanRenderer renderer = TextSpanRenderer(defaultStyle, yourTheme);\nresult.render(renderer);\nfinal TextSpan? span = renderer.span;\n\n// Pass the span to your Text Widget or TextEditingController.\n```\n\nMore codes please see `example`.\n\n## Principle and Build\n\nThe `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.\n\n- Install `gulp`.\n\n```\nnpm install gulp -g\n```\n\n- Sync `highlightjs` modules.\n\n```\ngit submodule update --remote --init\n```\n\n- Auto generated rule files.\n\n```\ncd tool\nnpm install\ngulp generate\n```\n\n- Run unit-tests.\n\n```\nflutter test\n```\n\nThe 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.\n\n## Used By\n\n- [re-editor](https://github.com/reqable/re-editor) A powerful lightweight text and code editor widget.\n\n## Issues and Features\n\nThe 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](https://github.com/highlightjs/highlight.js), and we will try to synchronize them as soon as possible.\n\nIf it's related to `Dart` or `Flutter`, it is welcome to submit an issue or PR in this project.\n\n## Sponsor\n\nIf 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](https://reqable.com/pricing) license.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freqable%2Fre-highlight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freqable%2Fre-highlight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freqable%2Fre-highlight/lists"}