{"id":20566305,"url":"https://github.com/trimorphdev/highlighter","last_synced_at":"2025-07-24T10:34:51.512Z","repository":{"id":58055422,"uuid":"529806898","full_name":"trimorphdev/highlighter","owner":"trimorphdev","description":"An extendable syntax highlighter written in Rust.","archived":false,"fork":false,"pushed_at":"2022-08-28T15:31:35.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-05T23:42:24.020Z","etag":null,"topics":["lexer","lexer-framework","rust","rust-crate","rust-crates","syntax","syntax-highlight","syntax-highlighting","syntax-highlighting-theme"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/trimorphdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-28T08:40:47.000Z","updated_at":"2022-08-28T15:33:53.000Z","dependencies_parsed_at":"2022-08-28T12:20:32.223Z","dependency_job_id":null,"html_url":"https://github.com/trimorphdev/highlighter","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/trimorphdev/highlighter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trimorphdev%2Fhighlighter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trimorphdev%2Fhighlighter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trimorphdev%2Fhighlighter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trimorphdev%2Fhighlighter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trimorphdev","download_url":"https://codeload.github.com/trimorphdev/highlighter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trimorphdev%2Fhighlighter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265829039,"owners_count":23835085,"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":["lexer","lexer-framework","rust","rust-crate","rust-crates","syntax","syntax-highlight","syntax-highlighting","syntax-highlighting-theme"],"created_at":"2024-11-16T04:41:02.960Z","updated_at":"2025-07-24T10:34:51.482Z","avatar_url":"https://github.com/trimorphdev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Highlighter\nAn extendable syntax highlighter written in Rust.\n\n## Installation\nSimply add highlighter to your dependencies:\n```toml\n[dependencies]\nhighlighter = \"0.1.1-alpha\"\n```\n\n## Basic Usage\n```rust\nuse highlighter::{highlight_language, HighlightTargetHtml};\n\nfn main() {\n    let result = highlight_language(\"brainheck\", \"++++++++ set current cell to 8\").unwrap().unwrap();\n    let html = HighlightTargetHtml::new()\n        .build(result);\n    println!(html);\n}\n```\n\n## Implementing Languages\nTo extend Highlighter, make a structure which implements the `Language` trait.\n\n```rust\nextern crate highlighter;\n\nuse highlighter::{core::language::{Language, Scope}, highlight, HighlighterTargetHtml};\n\n/// My example programming language\npub struct MyLanguage;\n\nimpl Language for MyLanguage {\n    fn name(\u0026self) -\u003e String {\n        \"my-language\".to_string()\n    }\n    \n    fn init(\u0026self, cx: \u0026mut highlighter::core::LexerContext) -\u003e Result\u003c(), highlighter::core::Error\u003e {\n        // Initialize the tokens in your language.\n        cx.token(Scope::KeywordControl, \"\\\\b(if|else|while|continue|break|return)\\\\b\")?;\n        cx.token(Scope::StorageType, \"\\\\b(var|function)\\\\b\")?;\n        cx.token(Scope::ConstantNumber, \"\\\\b([0-9][0-9_]*)\\\\b\")?;\n        cx.token(Scope::ConstantLanguage, \"\\\\b(true|false)\\\\b\")?;\n        Ok(())\n    }\n}\n\nfn main() {\n    let tokens = highlight(MyLanguage, \"var i = 0;\").unwrap();\n    let html = HighlighterTargetHtml::new()\n        .build(tokens);\n    \n    println!(\"{}\", html);\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrimorphdev%2Fhighlighter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrimorphdev%2Fhighlighter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrimorphdev%2Fhighlighter/lists"}