Languages and themes
Ferriki maintains its own catalog: a curated set of TextMate grammars, including embedding dependencies, and 65 themes. The package ships catalog metadata; grammar and theme payloads are downloaded and cached on first use by an asynchronous API call.
The standard catalog contains 67 standard grammars and 27 support grammars, 94 entries in all. Support grammars handle embedded syntax and injections; they are listed separately below.
See Ferriki vs Prism for real TypeScript, TSX, C++, Go, Rust, CSS, HTML, and Astro outputs, including the token distinctions available to themes.
Supported grammars
JSON, JSONC, JSON5, Markdown, MDX, YAML, and TOML are all included, along with
Handlebars, Liquid, and Glimmer's .gjs and .gts components. The tables
group the current catalog by typical use. Each row shows the ID to pass as
lang, followed by any interchangeable aliases.
- Documents and configuration (9)
- Web languages and components (12)
- Styles and templates (9)
- General-purpose programming (21)
- Infrastructure and automation (9)
- Game scripting (2)
- Queries and patterns (3)
- WebAssembly and graphics (2)
Documents and configuration
Documentation, content, package metadata, application settings, and data exchange.
| Grammar | Language ID and aliases |
|---|---|
| INI | iniAliases: properties |
| JSON | json |
| JSON with Comments | jsonc |
| JSON5 | json5 |
| Markdown | markdownAliases: md |
| MDX | mdx |
| TOML | toml |
| XML | xml |
| YAML | yamlAliases: yml |
Web languages and components
Browser and server JavaScript, React syntax, PHP, and component frameworks.
| Grammar | Language ID and aliases |
|---|---|
| Angular TypeScript | angular-ts |
| Astro | astro |
| Glimmer JS | glimmer-jsAliases: gjs |
| Glimmer TS | glimmer-tsAliases: gts |
| HTML | html |
| JavaScript | javascriptAliases: js, cjs, mjs |
| JSX | jsx |
| PHP | php |
| Svelte | svelte |
| TSX | tsx |
| TypeScript | typescriptAliases: ts, cts, mts |
| Vue | vue |
Styles and templates
Stylesheets, preprocessors, Handlebars and Liquid templates, CSS-in-JS, and Lit HTML/SVG templates.
| Grammar | Language ID and aliases |
|---|---|
| CSS | css |
| CSS-in-JS and CSS tagged templates | es-tag-css |
| Handlebars | handlebarsAliases: hbs, hjs |
| HTML/SVG tagged templates (Lit) | es-tag-html |
| Less | less |
| Liquid | liquid |
| Pug | pugAliases: jade |
| Sass | sass |
| SCSS | scss |
General-purpose programming
Backend services, systems software, desktop and mobile apps, scripting, and scientific computing.
| Grammar | Language ID and aliases |
|---|---|
| C | c |
| C# | csharpAliases: c#, cs |
| C++ | cppAliases: c++ |
| Clojure | clojureAliases: clj |
| Dart | dart |
| Elixir | elixirAliases: ex, exs |
| Gleam | gleam |
| Go | go |
| Haskell | haskellAliases: hs |
| Java | java |
| Julia | juliaAliases: jl |
| Kotlin | kotlinAliases: kt, kts |
| Lua | lua |
| Perl | perl |
| Python | pythonAliases: py |
| R | r |
| Ruby | rubyAliases: rb |
| Rust | rustAliases: rs |
| Scala | scala |
| Swift | swift |
| Zig | zig |
Infrastructure and automation
Shell scripts, build files, containers, infrastructure definitions, and code changes.
| Grammar | Language ID and aliases |
|---|---|
| CMake | cmake |
| Diff | diff |
| Dockerfile | dockerAliases: dockerfile |
| HashiCorp HCL | hcl |
| Makefile | makeAliases: makefile |
| Nix | nix |
| PowerShell | powershellAliases: ps, ps1, pwsh |
| Shell | shellscriptAliases: bash, sh, shell, zsh |
| Terraform | terraformAliases: tf, tfvars |
Game scripting
GDScript for Godot and Luau for Roblox and other Luau runtimes.
| Grammar | Language ID and aliases |
|---|---|
| GDScript | gdscriptAliases: gd |
| Luau | luau |
Queries and patterns
Database queries, GraphQL operations and schemas, and regular expressions.
| Grammar | Language ID and aliases |
|---|---|
| GraphQL | graphqlAliases: gql |
| RegExp | regexpAliases: regex |
| SQL | sql |
WebAssembly and graphics
WebAssembly text and WGSL shaders for WebGPU.
| Grammar | Language ID and aliases |
|---|---|
| WebAssembly | wasm |
| WGSL | wgsl |
Standard languages
Name a language by its ID or one of its aliases (ts, rs, sh, …):
import { bundledLanguages, bundledLanguagesAlias, createHighlighter } from "@ferriki/core";
const highlighter = await createHighlighter({
langs: ["typescript", bundledLanguages.rust],
themes: ["github-dark"],
});
const html = highlighter.codeToHtml("const answer = 42", {
lang: bundledLanguagesAlias.ts,
theme: "github-dark",
});
highlighter.dispose();
Required embedded languages load with their host: HTML brings CSS and
JavaScript for <style> and <script> blocks. Markdown and MDX keep optional
embeddings lazy. Load the languages used in your documents explicitly; code
fences follow the host grammar's supported fence rules.
JavaScript, TypeScript, JSX, and TSX also load HTML/SVG and CSS injections
automatically. Lit's html, svg, and css templates, Styled Components,
Emotion's tagged templates and CSS prop, and Styled JSX work with the host
language alone. Object-based styles use the regular JavaScript/TypeScript rules.
import { createHighlighter } from "@ferriki/core";
const highlighter = await createHighlighter({
langs: ["tsx"],
themes: ["github-dark"],
});
let html;
try {
html = highlighter.codeToHtml(
'const Button = styled.button`color: red;`;\nconst icon = svg`<circle cx="10" />`;',
{ lang: "tsx", theme: "github-dark" },
);
} finally {
highlighter.dispose();
}
For MDX, load tsx to highlight JSX and expressions, and yaml or toml
for frontmatter. For example:
import { createHighlighter } from "@ferriki/core";
const highlighter = await createHighlighter({
langs: ["mdx", "tsx", "yaml", "toml"],
themes: ["github-dark"],
});
let html;
try {
html = highlighter.codeToHtml('---\ntitle: Hello\n---\n\n# Hello\n\n<Greeting name="Ada" />', {
lang: "mdx",
theme: "github-dark",
});
} finally {
highlighter.dispose();
}
Included support grammars
These grammars supply syntax rules used by other entries: component expressions, embedded templates, documentation comments, and YAML versions. Required dependencies load with their host. Optional embedded languages highlight when the application loads them, as with Markdown fences. They contribute to the total grammar count rather than representing additional independent programming languages.
Component and template support
Expressions, directives, embedded markup, styles, and template syntax used by host grammars.
| Grammar | Language ID and aliases |
|---|---|
| Angular @let declarations | angular-let-declaration |
| Angular control-flow blocks | angular-template-blocks |
| Angular expressions | angular-expression |
| Angular HTML | angular-html |
| Angular inline styles | angular-inline-style |
| Angular inline templates | angular-inline-template |
| Angular template expressions | angular-template |
| CSS-in-JS declarations and interpolation | css-styled |
| Embedded HTML | html-derivative |
| Liquid embedded expressions | liquid-injection |
| Markdown in Vue | markdown-vue |
| PostCSS | postcss |
| Ruby Haml | haml |
| Vue directives | vue-directives |
| Vue interpolations | vue-interpolations |
| Vue style variables | vue-sfc-style-variable-injection |
Programming language support
C++ macros, Liquid Haskell annotations, Elixir EEx templates, JavaScript regular expressions, and documentation comments.
| Grammar | Language ID and aliases |
|---|---|
| C++ macros | cpp-macro |
| EEx templates in Elixir | eex |
| JavaScript regular expressions | js-regexp |
| JSDoc comments | jsdoc |
| Liquid Haskell annotations | annotation-liquidhaskell-haskell |
| SassDoc comments | sassdoc |
YAML versions and embeddings
Version-specific rules and embedded syntax selected by the YAML host grammar.
| Grammar | Language ID and aliases |
|---|---|
| Embedded YAML syntax | yaml-embedded |
| YAML 1.0 | yaml-1-0 |
| YAML 1.1 | yaml-1-1 |
| YAML 1.2 | yaml-1-2 |
| YAML 1.3 | yaml-1-3 |
Themes
Use any key of bundledThemes, such as github-light, github-dark,
nord or vitesse-dark. The special theme none returns unstyled output.
For light and dark output from one call, pass a themes map:
import { createHighlighter } from "@ferriki/core";
const highlighter = await createHighlighter({
langs: ["typescript"],
themes: ["github-light", "github-dark"],
});
let html;
try {
html = highlighter.codeToHtml("const answer: number = 42", {
lang: "typescript",
themes: { light: "github-light", dark: "github-dark" },
});
} finally {
highlighter.dispose();
}
createCssVariablesTheme builds a theme whose colors are CSS variables, for
sites that style highlighting from their own stylesheet.
For unchanged theme files with CSS classes instead of inline styles, see Class-based output.
Your own grammars and themes
The ferriki grammar fetch CLI imports external JSON TextMate grammars from
files, URLs, and commit-pinned GitHub sources, validates them with the native
engine, and records a source hash:
pnpm exec ferriki grammar fetch ./example.tmLanguage.json \
--name example --aliases example-syntax --output ./example.ferriki.json
Pass the generated registration to langs or loadLanguage. Convert YAML,
PLIST, and CSON to JSON before using this importer. Load dependency grammars
explicitly. Languages outside Ferriki's standard set use this same path.
A custom grammar or theme is the same JSON-shaped TextMate structure Shiki accepts. Ferriki validates it before it reaches the native engine:
import myGrammar from "./my-language.tmLanguage.json" with { type: "json" };
await highlighter.loadLanguage({ ...myGrammar, name: "my-language" });
highlighter.codeToHtml(source, { lang: "my-language", theme: "github-dark" });
A language registration needs name, scopeName and valid patterns; a theme
needs name and valid settings. Aliases of your own apply to one
highlighter; the standard aliases cannot be overwritten.