{"id":19351998,"url":"https://github.com/serverpod/syntax_highlight","last_synced_at":"2025-04-23T07:31:11.500Z","repository":{"id":181231519,"uuid":"666468448","full_name":"serverpod/syntax_highlight","owner":"serverpod","description":"A better syntax highlighter for Flutter.","archived":false,"fork":false,"pushed_at":"2024-03-15T12:03:32.000Z","size":403,"stargazers_count":38,"open_issues_count":6,"forks_count":11,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-02T09:51:15.687Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serverpod.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":"2023-07-14T15:40:09.000Z","updated_at":"2025-03-18T08:30:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"edb977b2-82f5-4fb4-8574-0b040a3c276b","html_url":"https://github.com/serverpod/syntax_highlight","commit_stats":null,"previous_names":["serverpod/syntax_highlight"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverpod%2Fsyntax_highlight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverpod%2Fsyntax_highlight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverpod%2Fsyntax_highlight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverpod%2Fsyntax_highlight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serverpod","download_url":"https://codeload.github.com/serverpod/syntax_highlight/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250391151,"owners_count":21422849,"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":[],"created_at":"2024-11-10T04:37:49.813Z","updated_at":"2025-04-23T07:31:10.420Z","avatar_url":"https://github.com/serverpod.png","language":"Dart","readme":"# Syntax Highlight\n\nThe Syntax Highlight package uses the TextMate rules for highlighting code, which is used by many popular applications such as VSCode. Currently supported languages are Dart, SQL (Postgres), and YAML, but it is easy to extend the language support by dropping in new grammar files in the `grammar` directory.\n\n## Usage\nBefore you can use the `Highlighter` class it needs to be initialized. The initialization will load the requested grammar files and parse them.\n\n```dart\n// Initialize the highlighter.\nawait Highlighter.initialize(['dart', 'yaml', 'sql']);\n```\n\nNext load a theme and create a highlighter.\n```dart\n// Load the default light theme and create a highlighter.\nvar theme = await HighlighterTheme.loadLightTheme();\nvar highlighter = Highlighter(\n  language: 'dart',\n  theme: theme,\n);\n```\n\nNow, you can highlight your code by calling the `highlight` method. The `highlight` method will return a `TextSpan`, which you can use in a `Text` widget.\n```dart\nWidget build(BuildContext context) {\n  var highlightedCode = highlighter.highlight(myCodeString);\n  return Text.rich(highlightedCode);\n}\n```\n\nAn example of highlighted code:\n![Highlighted code](https://raw.githubusercontent.com/serverpod/syntax_highlight/main/images/screenshot.png\n)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverpod%2Fsyntax_highlight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserverpod%2Fsyntax_highlight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverpod%2Fsyntax_highlight/lists"}