Skip to main content
The Deno 2 Release Candidate is here
Learn more
Go to Latest
interface LanguageMapProtocol
import { type LanguageMapProtocol } from "https://deno.land/x/frugal@0.5.0/docs/dep/prism.ts";

Methods

extend(id: string, redef: Grammar): Grammar

Creates a deep copy of the language with the given id and appends the given tokens.

If a token in redef also appears in the copied language, then the existing token in the copied language will be overwritten at its original position.

insertBefore(
inside: string,
before: string,
insert: Grammar,
root?: LanguageMap,
): Grammar

Inserts tokens before another token in a language definition or any other grammar.

As this needs to recreate the object (we cannot actually insert before keys in object literals), we cannot just provide an object, we need an object and a key.

If the grammar of inside and insert have tokens with the same name, the tokens in inside will be ignored.

All references of the old object accessible from Prism.languages or insert will be replace with the new one.