{"id":19065465,"url":"https://github.com/menci/syntect-js","last_synced_at":"2025-10-25T06:16:35.038Z","repository":{"id":57164140,"uuid":"446505441","full_name":"Menci/syntect-js","owner":"Menci","description":"Syntect (Syntax highlighter in Rust) for Node.js and WebAssembly","archived":false,"fork":false,"pushed_at":"2024-02-17T18:15:29.000Z","size":30,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-18T15:17:32.125Z","etag":null,"topics":["highlight","javascript","native-bindings","nodejs","rust","syntect","wasm","webassembly"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Menci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-01-10T16:47:27.000Z","updated_at":"2025-03-04T16:20:17.000Z","dependencies_parsed_at":"2024-10-09T14:54:43.711Z","dependency_job_id":null,"html_url":"https://github.com/Menci/syntect-js","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"246a013ed4d9eaca9b9525eb5fb94598c23f1487"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Menci%2Fsyntect-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Menci%2Fsyntect-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Menci%2Fsyntect-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Menci%2Fsyntect-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Menci","download_url":"https://codeload.github.com/Menci/syntect-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251303990,"owners_count":21567785,"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":["highlight","javascript","native-bindings","nodejs","rust","syntect","wasm","webassembly"],"created_at":"2024-11-09T00:50:05.182Z","updated_at":"2025-10-25T06:16:30.018Z","avatar_url":"https://github.com/Menci.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Syntect for Node.js and WASM\n\n[Syntect (Syntax highlighter in Rust)](https://github.com/trishume/syntect) for Node.js and WebAssembly.\n\nSyntect highlights code with TextMate's `.tmTheme` theme. And the highlighting result is independent of the theme (using CSS classes, unlike [Shiki](https://github.com/shikijs/shiki), which uses inline styles) so you can switch themes in your website by only switching CSS.\n\n\n```bash\n# Install the meta-package\nyarn add syntect       # Auto choose --\n                       # Native binding for Node.js\n                       # WebAssembly for browser\n\n# Or Install manually\nyarn add @syntect/node # Node.js native binding\nyarn add @syntect/wasm # WebAssembly\n```\n\n# Usage\n\n**Note:** See [WASM Notes](#wasm-notes) if you encountered any error using the WASM version.\n\n```typescript\nimport { getCSS, highlight } from \"syntect\" /* or \"@syntect/node\" / \"@syntect/wasm\" */;\n\n// Generate CSS code from .tmTheme file\nconst result = getCSS(\n  // The text content of .tmTheme file\n  tmThemeText,\n  // The prefix of CSS class name,\n  \"hl-\"\n);\nconsole.log(result.css);\n// Only needed once.\n// You could save the CSS file for your website.\n// See also [CLI]\n\n// Highlight code\nconst highlightResult = highlight(\n  // The code to highlight\n  \"#include \u003ccstdio\u003e\",\n  // The language name or file extension. Use \"plain\" or \"plaintext\" for plain text\n  \"cpp\",\n  // The prefix of CSS class name,\n  \"hl-\"\n);\nconsole.log(result.html);\n```\n\n# CLI\n\nThere's a cli utility for `getCSS` function. You should install the Node.js version (`syntect` or `@syntect/node`) to use it.\n\n```bash\n# Install with `yarn add syntect` or `yarn add @syntect/node`\n\n# yarn syntect-css \u003cprefix\u003e\ncat my-theme.tmTheme | yarn syntect-css hl-\n\n# e.g. the tomorrow theme\ncurl https://raw.githubusercontent.com/chriskempson/textmate-tomorrow-theme/master/Tomorrow.tmTheme | yarn syntect-css hl-\n```\n\n# WASM Notes\n\nThe WASM version has all code in ES Modules.\n\nTo use the WASM version with Node.js, please add `--experimental-wasm-modules` to your Node.js command line options to enable Node.js to load `.wasm` modules. For older version of Node.js you'll also need `--experimental-modules` to enable basic ES Modules support.\n\nTo use the WASM version in browser, you may need to configure your bundler:\n\n* *Webpack 5*: enable `experiments.asyncWebAssembly`.\n* *Vite*: use [vite-plugin-wasm](https://github.com/Menci/vite-plugin-wasm).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmenci%2Fsyntect-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmenci%2Fsyntect-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmenci%2Fsyntect-js/lists"}