Basic migration

This commit is contained in:
RunDevelopment 2023-05-30 16:47:05 +02:00
parent c5623b79b9
commit dda3777523
355 changed files with 1954 additions and 2027 deletions

View File

@ -22,7 +22,6 @@ export const PrismConfig = {
* ```
*
* @default false
* @type {boolean}
* @public
*/
manual: false
@ -30,7 +29,7 @@ export const PrismConfig = {
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
// Get current script and highlight
const script = /** @type {HTMLScriptElement | null} */ (document.currentScript);
const script = document.currentScript as HTMLScriptElement | null;
if (script && script.hasAttribute('data-manual')) {
PrismConfig.manual = true;
}

View File

@ -1,48 +0,0 @@
/**
* @typedef {(string | symbol) & { __keyType?: T }} StateKey
* @template {{}} T
*/
/**
* A simple typed map from some key to its data.
*/
export class HookState {
/**
* @type {Map<string | symbol, {}>}
* @private
*/
_data = new Map();
/**
* @param {StateKey<{}>} key
* @returns {boolean}
*/
has(key) {
return this._data.has(key);
}
/**
* @param {StateKey<T>} key
* @param {T} defaultValue
* @returns {T}
* @template {{}} T
*/
get(key, defaultValue) {
let current = this._data.get(key);
if (current === undefined) {
current = defaultValue;
this._data.set(key, current);
}
return /** @type {T} */ (current);
}
/**
* @param {StateKey<T>} key
* @param {T} value
* @returns {void}
* @template {{}} T
*/
set(key, value) {
this._data.set(key, value);
}
}

25
src/core/hook-state.ts Normal file
View File

@ -0,0 +1,25 @@
export type StateKey<T> = (string | symbol) & { __keyType?: T };
/**
* A simple typed map from some key to its data.
*/
export class HookState {
private _data = new Map<string | symbol, {}>();
has(key: StateKey<{}>): boolean {
return this._data.has(key);
}
get<T extends {}>(key: StateKey<T>, defaultValue: T) {
let current = this._data.get(key);
if (current === undefined) {
current = defaultValue;
this._data.set(key, current);
}
return current as T;
}
set<T extends {}>(key: StateKey<T>, value: T): void {
this._data.set(key, value);
}
}

View File

@ -1,67 +0,0 @@
export class Hooks {
constructor() {
/**
* @type {Map<string, ((env: any) => void)[]>}
* @private
*/
this._all = new Map();
}
/**
* Adds the given callback to the list of callbacks for the given hook and returns a function that
* removes the hook again when called.
*
* The callback will be invoked when the hook it is registered for is run.
* Hooks are usually directly run by a highlight function but you can also run hooks yourself.
*
* One callback function can be registered to multiple hooks.
*
* A callback function must not be registered for the same hook multiple times. Doing so will cause
* undefined behavior. However, registering a callback again after removing it is fine.
*
* @param {Name} name The name of the hook.
* @param {import("./hooks-env").HookCallback<Name>} callback The callback function which is given environment variables.
* @returns {() => void}
* @template {string} Name
* @public
*/
add(name, callback) {
let hooks = this._all.get(name);
if (hooks === undefined) {
hooks = [];
this._all.set(name, hooks);
}
const list = hooks;
list.push(callback);
return () => {
const index = list.indexOf(callback);
if (index !== -1) {
list.splice(index, 1);
}
};
}
/**
* Runs a hook invoking all registered callbacks with the given environment variables.
*
* Callbacks will be invoked synchronously and in the order in which they were registered.
*
* @param {Name} name The name of the hook.
* @param {import("./hooks-env").HookEnv<Name>} env The environment variables of the hook passed to all callbacks registered.
* @template {string} Name
* @public
*/
run(name, env) {
const callbacks = this._all.get(name);
if (!callbacks || !callbacks.length) {
return;
}
for (const callback of callbacks) {
callback(env);
}
}
}

View File

@ -1,6 +1,64 @@
import { Grammar, TokenName } from '../types';
import { HookState } from './hook-state';
import { TokenStream } from './token';
import type { Grammar, TokenName } from '../types';
import type { HookState } from './hook-state';
import type { TokenStream } from './token';
export class Hooks {
private _all = new Map<string, ((env: any) => void)[]>();
/**
* Adds the given callback to the list of callbacks for the given hook and returns a function that
* removes the hook again when called.
*
* The callback will be invoked when the hook it is registered for is run.
* Hooks are usually directly run by a highlight function but you can also run hooks yourself.
*
* One callback function can be registered to multiple hooks.
*
* A callback function must not be registered for the same hook multiple times. Doing so will cause
* undefined behavior. However, registering a callback again after removing it is fine.
*
* @param name The name of the hook.
* @param callback The callback function which is given environment variables.
*/
add<Name extends string>(name: Name, callback: HookCallback<Name>): () => void {
let hooks = this._all.get(name);
if (hooks === undefined) {
hooks = [];
this._all.set(name, hooks);
}
const list = hooks;
list.push(callback);
return () => {
const index = list.indexOf(callback);
if (index !== -1) {
list.splice(index, 1);
}
};
}
/**
* Runs a hook invoking all registered callbacks with the given environment variables.
*
* Callbacks will be invoked synchronously and in the order in which they were registered.
*
* @param name The name of the hook.
* @param env The environment variables of the hook passed to all callbacks registered.
*/
run<Name extends string>(name: Name, env: HookEnv<Name>): void {
const callbacks = this._all.get(name);
if (!callbacks || !callbacks.length) {
return;
}
for (const callback of callbacks) {
callback(env);
}
}
}
/**
* An interface containing all hooks Prism runs.
@ -52,19 +110,19 @@ export interface BeforeSanityCheckEnv extends StatefulEnv {
grammar: Grammar | undefined;
code: string;
}
export interface BeforeHighlightEnv extends StatefulEnv{
export interface BeforeHighlightEnv extends StatefulEnv {
element: Element;
language: string;
grammar: Grammar | undefined;
code: string;
}
export interface CompleteEnv extends StatefulEnv{
export interface CompleteEnv extends StatefulEnv {
element: Element;
language: string;
grammar: Grammar | undefined;
code: string;
}
export interface BeforeInsertEnv extends StatefulEnv{
export interface BeforeInsertEnv extends StatefulEnv {
element: Element;
language: string;
grammar: Grammar | undefined;

View File

@ -1,91 +0,0 @@
/**
* @typedef LinkedListMiddleNode
* @property {T} value
* @property {LinkedListMiddleNode<T> | LinkedListHeadNode<T>} prev
* @property {LinkedListMiddleNode<T> | LinkedListTailNode<T>} next
* @template T
*/
/**
* @typedef LinkedListHeadNode
* @property {null} value
* @property {null} prev
* @property {LinkedListMiddleNode<T> | LinkedListTailNode<T>} next
* @template T
*/
/**
* @typedef LinkedListTailNode
* @property {null} value
* @property {LinkedListMiddleNode<T> | LinkedListHeadNode<T>} prev
* @property {null} next
* @template T
*/
/**
* @typedef {LinkedListHeadNode<T> | LinkedListTailNode<T> | LinkedListMiddleNode<T>} LinkedListNode
* @template T
*/
/**
* @template T
*/
export class LinkedList {
constructor() {
/** @type {LinkedListHeadNode<T>} */
const head = { value: null, prev: null, next: /** @type {any} */ (null) };
/** @type {LinkedListTailNode<T>} */
const tail = { value: null, prev: head, next: null };
head.next = tail;
this.head = head;
this.tail = tail;
this.length = 0;
}
/**
* Adds a new node with the given value to the list.
*
* @param {LinkedListHeadNode<T> | LinkedListMiddleNode<T>} node
* @param {T} value
* @returns {LinkedListMiddleNode<T>} The added node.
*/
addAfter(node, value) {
// assumes that node != list.tail && values.length >= 0
const next = node.next;
const newNode = { value, prev: node, next };
node.next = newNode;
next.prev = newNode;
this.length++;
return newNode;
}
/**
* Removes `count` nodes after the given node. The given node will not be removed.
*
* @param {LinkedListHeadNode<T> | LinkedListMiddleNode<T>} node
* @param {number} count
*/
removeRange(node, count) {
let next = node.next;
let i = 0;
for (; i < count && next.next !== null; i++) {
next = next.next;
}
node.next = next;
next.prev = node;
this.length -= i;
}
/**
* @returns {T[]}
*/
toArray() {
const array = [];
let node = this.head.next;
while (node.next !== null) {
array.push(node.value);
node = node.next;
}
return array;
}
}

74
src/core/linked-list.ts Normal file
View File

@ -0,0 +1,74 @@
export interface LinkedListMiddleNode<T> {
value: T;
prev: LinkedListMiddleNode<T> | LinkedListHeadNode<T>;
next: LinkedListMiddleNode<T> | LinkedListTailNode<T>;
}
export interface LinkedListHeadNode<T> {
value: null;
prev: null;
next: LinkedListMiddleNode<T> | LinkedListTailNode<T>;
}
export interface LinkedListTailNode<T> {
value: null;
prev: LinkedListMiddleNode<T> | LinkedListHeadNode<T>;
next: null;
}
export class LinkedList<T> {
readonly head: LinkedListHeadNode<T>;
readonly tail: LinkedListTailNode<T>;
length: number;
constructor() {
const head: LinkedListHeadNode<T> = { value: null, prev: null, next: null as any };
const tail: LinkedListTailNode<T> = { value: null, prev: head, next: null };
head.next = tail;
this.head = head;
this.tail = tail;
this.length = 0;
}
/**
* Adds a new node with the given value to the list.
*
* @param node
* @param value
* @returns The added node.
*/
addAfter(node: LinkedListHeadNode<T> | LinkedListMiddleNode<T>, value: T): LinkedListMiddleNode<T> {
// assumes that node != list.tail && values.length >= 0
const next = node.next;
const newNode = { value, prev: node, next };
node.next = newNode;
next.prev = newNode;
this.length++;
return newNode;
}
/**
* Removes `count` nodes after the given node. The given node will not be removed.
*/
removeRange(node: LinkedListHeadNode<T> | LinkedListMiddleNode<T>, count: number): void {
let next = node.next;
let i = 0;
for (; i < count && next.next !== null; i++) {
next = next.next;
}
node.next = next;
next.prev = node;
this.length -= i;
}
toArray(): T[] {
const array: T[] = [];
let node = this.head.next;
while (node.next !== null) {
array.push(node.value);
node = node.next;
}
return array;
}
}

View File

@ -1,37 +0,0 @@
import { Grammar } from '../types';
export interface AsyncHighlightingData {
language: string;
code: string;
grammar: Grammar;
}
export type AsyncHighlighter = (data: AsyncHighlightingData) => Promise<string>;
export interface HighlightAllOptions {
/**
* The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
*/
root?: ParentNode;
async?: AsyncHighlighter;
/**
* An optional callback to be invoked on each element after its highlighting is done.
*
* @see HighlightElementOptions.callback
*/
callback?: (element: Element) => void;
}
export interface HighlightElementOptions {
async?: AsyncHighlighter;
/**
* An optional callback to be invoked after the highlighting is done.
* Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
*
* @param element The element successfully highlighted.
*/
callback?: (element: Element) => void;
}
export interface HighlightOptions {
grammar?: Grammar;
}

View File

@ -1,15 +1,13 @@
import type { KnownPlugins } from '../known-plugins';
import { getLanguage, setLanguage } from '../shared/dom-util';
import { rest, tokenize } from '../shared/symbols';
import { htmlEncode } from '../shared/util';
import type { Grammar, GrammarToken, GrammarTokens } from '../types';
import { HookState } from './hook-state';
import { Hooks } from './hooks';
import { LinkedList } from './linked-list';
import { HookEnvMap, Hooks } from './hooks';
import { LinkedList, LinkedListHeadNode, LinkedListMiddleNode, LinkedListTailNode } from './linked-list';
import { Registry } from './registry';
import { Token } from './token';
/**
* @typedef {import("./hooks-env").HookEnvMap} EnvMap
*/
import { Token, TokenStream } from './token';
/**
* Prism: Lightweight, robust, elegant syntax highlighting
@ -18,14 +16,10 @@ import { Token } from './token';
* @author Lea Verou <https://lea.verou.me>
*/
export class Prism {
constructor() {
this.hooks = new Hooks();
this.components = new Registry(this);
/**
* @type {Partial<Record<string, unknown> & import('../known-plugins').KnownPlugins>}
*/
this.plugins = {};
}
hooks = new Hooks();
components = new Registry(this);
plugins: Partial<Record<string, unknown> & KnownPlugins> = {};
/**
* This is the most high-level function in Prisms API.
@ -36,13 +30,11 @@ export class Prism {
* 1. `before-highlightall`
* 2. `before-all-elements-highlight`
* 3. All hooks of {@link Prism#highlightElement} for each element.
*
* @param {import("./prism-types").HighlightAllOptions} [options]
*/
highlightAll(options = {}) {
highlightAll(options: HighlightAllOptions = {}) {
const { root, async, callback } = options;
const env = /** @type {EnvMap["before-highlightall"] | EnvMap["before-all-elements-highlight"]} */ ({
const env: HookEnvMap["before-highlightall"] | HookEnvMap["before-all-elements-highlight"] = ({
callback,
root: root ?? document,
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code',
@ -77,11 +69,10 @@ export class Prism {
* Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
* the element's language.
*
* @param {Element} element The element containing the code.
* @param element The element containing the code.
* It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
* @param {import("./prism-types").HighlightElementOptions} [options]
*/
highlightElement(element, options = {}) {
highlightElement(element: Element, options: HighlightElementOptions = {}) {
const { async, callback } = options;
// Find language
@ -98,10 +89,9 @@ export class Prism {
setLanguage(parent, language);
}
const code = /** @type {string} */ (element.textContent);
const code = element.textContent as string;
/** @type {EnvMap["before-sanity-check"]} */
const env = {
const env: HookEnvMap["before-sanity-check"] = {
element,
language,
grammar,
@ -109,8 +99,7 @@ export class Prism {
state: new HookState()
};
/** @param {string} highlightedCode */
const insertHighlightedCode = (highlightedCode) => {
const insertHighlightedCode = (highlightedCode: string) => {
// @ts-ignore
env.highlightedCode = highlightedCode;
@ -167,21 +156,20 @@ export class Prism {
* 2. `after-tokenize`
* 3. `wrap`: On each {@link Token}.
*
* @param {string} text A string with the code to be highlighted.
* @param {string} language The name of the language definition passed to `grammar`.
* @param {import("./prism-types").HighlightOptions} [options] An object containing the tokens to use.
* @param text A string with the code to be highlighted.
* @param language The name of the language definition passed to `grammar`.
* @param options An object containing the tokens to use.
*
* Usually a language definition like `Prism.languages.markup`.
* @returns {string} The highlighted HTML.
* @returns The highlighted HTML.
* @example
* Prism.highlight('var foo = true;', 'javascript');
*/
highlight(text, language, options) {
highlight(text: string, language: string, options: HighlightOptions): string {
const languageId = this.components.resolveAlias(language);
const grammar = options?.grammar ?? this.components.getLanguage(languageId);
/** @type {EnvMap["before-tokenize"] | EnvMap["after-tokenize"]} */
const env = ({
const env: HookEnvMap["before-tokenize"] | HookEnvMap["after-tokenize"] = ({
code: text,
grammar,
language
@ -207,11 +195,11 @@ export class Prism {
*
* This method could be useful in other contexts as well, as a very crude parser.
*
* @param {string} text A string with the code to be highlighted.
* @param {import("../types").Grammar} grammar An object containing the tokens to use.
* @param text A string with the code to be highlighted.
* @param grammar An object containing the tokens to use.
*
* Usually a language definition like `Prism.languages.markup`.
* @returns {import("./token").TokenStream} An array of strings and tokens, a token stream.
* @returns An array of strings and tokens, a token stream.
* @example
* let code = `var foo = 0;`;
* let tokens = Prism.tokenize(code, Prism.getLanguage('javascript'));
@ -221,7 +209,7 @@ export class Prism {
* }
* });
*/
tokenize(text, grammar) {
tokenize(text: string, grammar: Grammar): TokenStream {
const customTokenize = grammar[tokenize];
if (customTokenize) {
return customTokenize(text, grammar, this);
@ -233,8 +221,7 @@ export class Prism {
restGrammar = resolve(this.components, restGrammar[rest]);
}
/** @type {LinkedList<string | Token>} */
const tokenList = new LinkedList();
const tokenList = new LinkedList<string | Token>();
tokenList.addAfter(tokenList.head, text);
this._matchGrammar(text, tokenList, grammar, tokenList.head, 0);
@ -242,21 +229,14 @@ export class Prism {
return tokenList.toArray();
}
/**
* @param {string} text
* @param {LinkedList<string | Token>} tokenList
* @param {import("../types").GrammarTokens} grammar
* @param {import("./linked-list").LinkedListHeadNode<string | Token> | import("./linked-list").LinkedListMiddleNode<string | Token>} startNode
* @param {number} startPos
* @param {RematchOptions} [rematch]
* @returns {void}
* @private
*
* @typedef RematchOptions
* @property {string} cause
* @property {number} reach
*/
_matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
private _matchGrammar(
text: string,
tokenList: LinkedList<string | Token>,
grammar: GrammarTokens,
startNode: LinkedListHeadNode<string | Token> | LinkedListMiddleNode<string | Token>,
startPos: number,
rematch?: RematchOptions
): void {
for (const token in grammar) {
const tokenValue = grammar[token];
if (!grammar.hasOwnProperty(token) || !tokenValue) {
@ -332,8 +312,7 @@ export class Prism {
}
// find the last node which is affected by this match
/** @type {import("./linked-list").LinkedListMiddleNode<Token | string> | import("./linked-list").LinkedListTailNode<Token | string>} */
let k = currentNode;
let k: LinkedListMiddleNode<Token | string> | LinkedListTailNode<Token | string> = currentNode;
for (; k.next !== null && (p < to || typeof k.value === 'string'); k = k.next) {
removeCount++;
p += k.value.length;
@ -381,8 +360,7 @@ export class Prism {
// at least one Token object was removed, so we have to do some rematching
// this can only happen if the current pattern is greedy
/** @type {RematchOptions} */
const nestedRematch = {
const nestedRematch: RematchOptions = {
cause: token + ',' + j,
reach
};
@ -399,15 +377,49 @@ export class Prism {
}
}
interface RematchOptions {
cause: string;
reach: number;
}
/**
* @param {RegExp} pattern
* @param {number} pos
* @param {string} text
* @param {boolean} lookbehind
* @returns {RegExpExecArray | null}
*/
function matchPattern(pattern, pos, text, lookbehind) {
export interface AsyncHighlightingData {
language: string;
code: string;
grammar: Grammar;
}
export type AsyncHighlighter = (data: AsyncHighlightingData) => Promise<string>;
export interface HighlightAllOptions {
/**
* The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
*/
root?: ParentNode;
async?: AsyncHighlighter;
/**
* An optional callback to be invoked on each element after its highlighting is done.
*
* @see HighlightElementOptions.callback
*/
callback?: (element: Element) => void;
}
export interface HighlightElementOptions {
async?: AsyncHighlighter;
/**
* An optional callback to be invoked after the highlighting is done.
* Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
*
* @param element The element successfully highlighted.
*/
callback?: (element: Element) => void;
}
export interface HighlightOptions {
grammar?: Grammar;
}
function matchPattern(pattern: RegExp, pos: number, text: string, lookbehind: boolean) {
pattern.lastIndex = pos;
const match = pattern.exec(text);
if (match && lookbehind && match[1]) {
@ -426,12 +438,11 @@ function matchPattern(pattern, pos, text, lookbehind) {
* The following hooks will be run:
* 1. `wrap`: On each {@link Token}.
*
* @param {string | Token | import("./token").TokenStream} o The token or token stream to be converted.
* @param {string} language The name of current language.
* @param {Hooks} hooks
* @returns {string} The HTML representation of the token or token stream.
* @param o The token or token stream to be converted.
* @param language The name of current language.
* @returns The HTML representation of the token or token stream.
*/
function stringify(o, language, hooks) {
function stringify(o: string | Token | TokenStream, language: string, hooks: Hooks): string {
if (typeof o === 'string') {
return htmlEncode(o);
}
@ -443,8 +454,7 @@ function stringify(o, language, hooks) {
return s;
}
/** @type {EnvMap["wrap"]} */
const env = {
const env: HookEnvMap["wrap"] = {
type: o.type,
content: stringify(o.content, language, hooks),
tag: 'span',
@ -472,11 +482,7 @@ function stringify(o, language, hooks) {
return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
}
/**
* @param {import("../types").GrammarToken | RegExp} pattern
* @returns {import("../types").GrammarToken}
*/
function toGrammarToken(pattern) {
function toGrammarToken(pattern: GrammarToken | RegExp): GrammarToken {
if (pattern.exec) {
return { pattern };
} else {
@ -484,12 +490,7 @@ function toGrammarToken(pattern) {
}
}
/**
* @param {Registry} components
* @param {import("../types").Grammar | string | null | undefined} reference
* @returns {import("../types").Grammar | undefined}
*/
function resolve(components, reference) {
function resolve(components: Registry, reference: Grammar | string | null | undefined): Grammar | undefined {
if (reference) {
if (typeof reference === 'string') {
return components.getLanguage(reference);

View File

@ -1,12 +1,13 @@
import { extend } from '../shared/language-util';
import { forEach, kebabToCamelCase } from '../shared/util';
import { ComponentProto, Grammar } from '../types';
import type { Prism } from './prism';
/**
* @typedef Entry
* @property {import('../types').ComponentProto} proto
* @property {import('../types').Grammar} [evaluatedGrammar]
* @property {() => void} [evaluatedEffect]
*/
interface Entry {
proto: ComponentProto;
evaluatedGrammar?: Grammar;
evaluatedEffect?: () => void;
}
/**
* TODO: docs
@ -14,62 +15,39 @@ import { forEach, kebabToCamelCase } from '../shared/util';
export class Registry {
/**
* A map from the aliases of components to the id of the component with that alias.
*
* @type {Map<string, string>}
* @private
*/
aliasMap = new Map();
private aliasMap = new Map<string, string>();
/**
* A map from the aliases of components to the id of the component with that alias.
*
* @type {Map<string, Entry>}
* @private
*/
entries = new Map();
private entries = new Map<string, Entry>();
/**
* @param {import('./prism').Prism} Prism
*/
constructor(Prism) {
/**
* @private
*/
private Prism: Prism;
constructor(Prism: Prism) {
this.Prism = Prism;
}
/**
* If the given name is a known alias, then the id of the component of the alias will be returned. Otherwise, the
* `name` will be returned as is.
*
* @param {string} name
* @returns {string}
*/
resolveAlias(name) {
resolveAlias(name: string): string {
return this.aliasMap.get(name) ?? name;
}
/**
* Returns whether this registry has a component with the given name or alias.
*
* @param {string} name
* @returns {boolean}
*/
has(name) {
has(name: string): boolean {
return this.entries.has(this.resolveAlias(name));
}
/**
* @param {import('../types').ComponentProto[]} components
*/
add(...components) {
/** @type {Set<string>} */
const added = new Set();
add(...components: ComponentProto[]): void {
const added = new Set<string>();
/**
* @param {import('../types').ComponentProto} proto
*/
const register = (proto) => {
const register = (proto: ComponentProto) => {
const { id } = proto;
if (this.entries.has(id)) {
return;
@ -86,7 +64,7 @@ export class Registry {
// add plugin namespace
if ('plugin' in proto && proto.plugin) {
this.Prism.plugins[kebabToCamelCase(id)] = proto.plugin(/** @type {any} */ (this.Prism));
this.Prism.plugins[kebabToCamelCase(id)] = proto.plugin(this.Prism as any);
}
};
components.forEach(register);
@ -94,23 +72,11 @@ export class Registry {
this.update(added);
}
/**
* @param {ReadonlySet<string>} changed
* @returns {void}
* @private
*/
update(changed) {
/** @type {Map<string, boolean>} */
const updateStatus = new Map();
private update(changed: ReadonlySet<string>): void {
const updateStatus = new Map<string, boolean>();
const idStack: string[] = [];
/** @type {string[]} */
const idStack = [];
/**
* @param {string} id
* @returns {boolean}
*/
const didUpdate = (id) => {
const didUpdate = (id: string): boolean => {
let status = updateStatus.get(id);
if (status !== undefined) {
return status;
@ -144,18 +110,13 @@ export class Registry {
// redo effects
if (entry.proto.effect) {
entry.evaluatedEffect = entry.proto.effect(/** @type {any} */ (this.Prism));
entry.evaluatedEffect = entry.proto.effect(this.Prism as any);
}
updateStatus.set(id, status = true);
return status;
};
/**
* @param {import('../types').ComponentProto} proto
* @returns {boolean}
*/
const shouldRunEffects = (proto) => {
/** @type {boolean} */
const shouldRunEffects = (proto: ComponentProto): boolean => {
let depsChanged = false;
forEach(proto.require, ({ id }) => {
@ -175,11 +136,7 @@ export class Registry {
this.entries.forEach((_, id) => didUpdate(id));
}
/**
* @param {string} id
* @returns {import("../types").Grammar | undefined}
*/
getLanguage(id) {
getLanguage(id: string): Grammar | undefined {
id = this.resolveAlias(id);
const entry = this.entries.get(id);
@ -200,10 +157,7 @@ export class Registry {
return entry.evaluatedGrammar = grammar;
}
/**
* @param {string} id
*/
const required = (id) => {
const required = (id: string) => {
const grammar = this.getLanguage(id);
if (!grammar) {
throw new Error(`The language ${id} was not found.`);

View File

@ -1,89 +0,0 @@
export class Token {
/**
* Creates a new token.
*
* @param {import("../types").TokenName} type See {@link Token#type type}
* @param {string | TokenStream} content See {@link Token#content content}
* @param {import("../types").TokenName | import("../types").TokenName[]} [alias] The alias(es) of the token.
* @param {string} [matchedStr=""] A copy of the full string this token was created from.
* @public
*/
constructor(type, content, alias, matchedStr = '') {
/**
* The type of the token.
*
* This is usually the key of a pattern in a {@link Grammar}.
*
* @type {import("../types").TokenName}
* @see GrammarToken
* @public
*/
this.type = type;
/**
* The strings or tokens contained by this token.
*
* This will be a token stream if the pattern matched also defined an `inside` grammar.
*
* @type {string | TokenStream}
* @public
*/
this.content = content;
/**
* The alias(es) of the token.
*
* @type {undefined | import("../types").TokenName | import("../types").TokenName[]}
* @see GrammarToken
* @public
*/
this.alias = alias;
// Copy of the full string this token was created from
this.length = matchedStr.length;
}
/**
* Adds the given alias to the list of aliases of this token.
*
* @param {import("../types").TokenName} alias
*/
addAlias(alias) {
let aliases = this.alias;
if (!aliases) {
this.alias = aliases = [];
} else if (!Array.isArray(aliases)) {
this.alias = aliases = [aliases];
}
aliases.push(alias);
}
}
/**
* A token stream is an array of strings and {@link Token Token} objects.
*
* Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
* them.
*
* 1. No adjacent strings.
* 2. No empty strings.
*
* The only exception here is the token stream that only contains the empty string and nothing else.
*
* @typedef {Array<string | Token>} TokenStream
* @public
*/
/**
* Returns the text content of the given token or token stream.
*
* @param {string | Token | TokenStream} token
* @returns {string}
*/
export function getTextContent(token) {
if (typeof token === 'string') {
return token;
} else if (Array.isArray(token)) {
return token.map(getTextContent).join('');
} else {
return getTextContent(token.content);
}
}

88
src/core/token.ts Normal file
View File

@ -0,0 +1,88 @@
import type { TokenName, Grammar, GrammarToken } from "../types";
export class Token {
/**
* The type of the token.
*
* This is usually the key of a pattern in a {@link Grammar}.
*
* @see {@link GrammarToken}
*/
type: TokenName
/**
* The strings or tokens contained by this token.
*
* This will be a token stream if the pattern matched also defined an `inside` grammar.
*/
content: string | TokenStream
/**
* The alias(es) of the token.
*
* @see {@link GrammarToken#alias}
*/
alias?: TokenName | TokenName[]
/**
* Length of the full string this token was created from.
*
* Only used internally. The API does not guarantee that this field has any particular value or meaning.
*
* @internal
*/
length: number
/**
* Creates a new token.
*
* @param type See {@link Token#type}
* @param content See {@link Token#content}
* @param alias The alias(es) of the token.
* @param matchedStr A copy of the full string this token was created from.
* @public
*/
constructor(type: TokenName, content: string | TokenStream, alias?: TokenName | TokenName[], matchedStr: string = '') {
this.type = type;
this.content = content;
this.alias = alias;
this.length = matchedStr.length;
}
/**
* Adds the given alias to the list of aliases of this token.
*/
addAlias(alias: TokenName): void {
let aliases = this.alias;
if (!aliases) {
this.alias = aliases = [];
} else if (!Array.isArray(aliases)) {
this.alias = aliases = [aliases];
}
aliases.push(alias);
}
}
/**
* A token stream is an array of strings and {@link Token Token} objects.
*
* Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
* them.
*
* 1. No adjacent strings.
* 2. No empty strings.
*
* The only exception here is the token stream that only contains the empty string and nothing else.
*/
export type TokenStream = (string | Token)[]
/**
* Returns the text content of the given token or token stream.
*/
export function getTextContent(token: string | Token | TokenStream): string {
if (typeof token === 'string') {
return token;
} else if (Array.isArray(token)) {
return token.map(getTextContent).join('');
} else {
return getTextContent(token.content);
}
}

View File

@ -3,7 +3,7 @@ import { Prism } from './core/prism';
const globalSymbol = Symbol.for('Prism global');
// eslint-disable-next-line no-undef
const namespace = /** @type {Partial<Record<globalSymbol, Prism>>} */ (globalThis);
const namespace = globalThis as Partial<Record<typeof globalSymbol, Prism>>;
const globalPrism = namespace[globalSymbol] ??= new Prism();
/**

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'abap'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'abap',
grammar: {
'comment': /^\*.*/m,
@ -48,4 +50,4 @@ export default /** @type {import("../types").LanguageProto<'abap'>} */ ({
}],
'punctuation': /[,.:()]/
}
});
} as LanguageProto<'abap'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'abnf'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'abnf',
grammar() {
const coreRules = '(?:ALPHA|BIT|CHAR|CR|CRLF|CTL|DIGIT|DQUOTE|HEXDIG|HTAB|LF|LWSP|OCTET|SP|VCHAR|WSP)';
@ -52,4 +54,4 @@ export default /** @type {import("../types").LanguageProto<'abnf'>} */ ({
'punctuation': /[()\[\]]/
};
}
});
} as LanguageProto<'abnf'>

View File

@ -1,7 +1,8 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import javascript from './prism-javascript';
export default /** @type {import("../types").LanguageProto<'actionscript'>} */ ({
export default {
id: 'actionscript',
require: javascript,
grammar({ extend }) {
@ -29,4 +30,4 @@ export default /** @type {import("../types").LanguageProto<'actionscript'>} */ (
return actionscript;
}
});
} as LanguageProto<'actionscript'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'ada'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'ada',
grammar: {
'comment': /--.*/,
@ -22,4 +24,4 @@ export default /** @type {import("../types").LanguageProto<'ada'>} */ ({
'char': /'.'/,
'variable': /\b[a-z](?:\w)*\b/i
}
});
} as LanguageProto<'ada'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'agda'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'agda',
grammar: {
'comment': /\{-[\s\S]*?(?:-\}|$)|--.*/,
@ -21,4 +23,4 @@ export default /** @type {import("../types").LanguageProto<'agda'>} */ ({
},
'keyword': /\b(?:Set|abstract|constructor|data|eta-equality|field|forall|hiding|import|in|inductive|infix|infixl|infixr|instance|let|macro|module|mutual|no-eta-equality|open|overlap|pattern|postulate|primitive|private|public|quote|quoteContext|quoteGoal|quoteTerm|record|renaming|rewrite|syntax|tactic|unquote|unquoteDecl|unquoteDef|using|variable|where|with)\b/,
}
});
} as LanguageProto<'agda'>

View File

@ -1,6 +1,8 @@
import type { LanguageProto } from "../types";
// based on https://github.com/microsoft/AL/blob/master/grammar/alsyntax.tmlanguage
export default /** @type {import("../types").LanguageProto<'al'>} */ ({
export default {
id: 'al',
grammar: {
'comment': /\/\/.*|\/\*[\s\S]*?\*\//,
@ -25,4 +27,4 @@ export default /** @type {import("../types").LanguageProto<'al'>} */ ({
'operator': /\.\.|:[=:]|[-+*/]=?|<>|[<>]=?|=|\b(?:and|div|mod|not|or|xor)\b/i,
'punctuation': /[()\[\]{}:.;,]/
}
});
} as LanguageProto<'al'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'antlr4'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'antlr4',
alias: 'g4',
grammar: {
@ -64,4 +66,4 @@ export default /** @type {import("../types").LanguageProto<'antlr4'>} */ ({
'operator': /\.\.|->|[|~]|[*+?]\??/,
'punctuation': /[;:()=]/
}
});
} as LanguageProto<'antlr4'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'apacheconf'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'apacheconf',
grammar: {
'comment': /#.*/,
@ -47,4 +49,4 @@ export default /** @type {import("../types").LanguageProto<'apacheconf'>} */ ({
'variable': /[$%]\{?(?:\w\.?[-+:]?)+\}?/,
'regex': /\^?.*\$|\^.*\$?/
}
});
} as LanguageProto<'apacheconf'>

View File

@ -1,7 +1,8 @@
import type { LanguageProto } from "../types";
import clike from './prism-clike';
import sql from './prism-sql';
export default /** @type {import("../types").LanguageProto<'apex'>} */ ({
export default {
id: 'apex',
require: [clike, sql],
grammar({ getLanguage }) {
@ -69,4 +70,4 @@ export default /** @type {import("../types").LanguageProto<'apex'>} */ ({
'punctuation': /[()\[\]{};,.]/
};
}
});
} as LanguageProto<'apex'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'apl'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'apl',
grammar: {
'comment': /(?:⍝|#[! ]).*$/m,
@ -32,4 +34,4 @@ export default /** @type {import("../types").LanguageProto<'apl'>} */ ({
alias: 'builtin'
}
}
});
} as LanguageProto<'apl'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'applescript'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'applescript',
grammar: {
'comment': [
@ -17,4 +19,4 @@ export default /** @type {import("../types").LanguageProto<'applescript'>} */ ({
'class-name': /\b(?:POSIX file|RGB color|alias|application|boolean|centimeters|centimetres|class|constant|cubic centimeters|cubic centimetres|cubic feet|cubic inches|cubic meters|cubic metres|cubic yards|date|degrees Celsius|degrees Fahrenheit|degrees Kelvin|feet|file|gallons|grams|inches|integer|kilograms|kilometers|kilometres|list|liters|litres|meters|metres|miles|number|ounces|pounds|quarts|real|record|reference|script|square feet|square kilometers|square kilometres|square meters|square metres|square miles|square yards|text|yards)\b/,
'punctuation': /[{}():,¬«»《》]/
}
});
} as LanguageProto<'applescript'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'aql'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'aql',
grammar: {
'comment': /\/\/.*|\/\*[\s\S]*?\*\//,
@ -49,4 +51,4 @@ export default /** @type {import("../types").LanguageProto<'aql'>} */ ({
'operator': /\*{2,}|[=!]~|[!=<>]=?|&&|\|\||[-+*/%]/,
'punctuation': /::|[?.:,;()[\]{}]/
}
});
} as LanguageProto<'aql'>

View File

@ -1,6 +1,7 @@
import type { LanguageProto } from "../types";
import cpp from './prism-cpp';
export default /** @type {import("../types").LanguageProto<'arduino'>} */ ({
export default {
id: 'arduino',
require: cpp,
alias: 'ino',
@ -11,4 +12,4 @@ export default /** @type {import("../types").LanguageProto<'arduino'>} */ ({
'builtin': /\b(?:Audio|BSSID|Bridge|Client|Console|EEPROM|Esplora|EsploraTFT|Ethernet|EthernetClient|EthernetServer|EthernetUDP|File|FileIO|FileSystem|Firmata|GPRS|GSM|GSMBand|GSMClient|GSMModem|GSMPIN|GSMScanner|GSMServer|GSMVoiceCall|GSM_SMS|HttpClient|IPAddress|IRread|Keyboard|KeyboardController|LiquidCrystal|LiquidCrystal_I2C|Mailbox|Mouse|MouseController|PImage|Process|RSSI|RobotControl|RobotMotor|SD|SPI|SSID|Scheduler|Serial|Server|Servo|SoftwareSerial|Stepper|Stream|TFT|Task|USBHost|WiFi|WiFiClient|WiFiServer|WiFiUDP|Wire|YunClient|YunServer|abs|addParameter|analogRead|analogReadResolution|analogReference|analogWrite|analogWriteResolution|answerCall|attach|attachGPRS|attachInterrupt|attached|autoscroll|available|background|beep|begin|beginPacket|beginSD|beginSMS|beginSpeaker|beginTFT|beginTransmission|beginWrite|bit|bitClear|bitRead|bitSet|bitWrite|blink|blinkVersion|buffer|changePIN|checkPIN|checkPUK|checkReg|circle|cityNameRead|cityNameWrite|clear|clearScreen|click|close|compassRead|config|connect|connected|constrain|cos|countryNameRead|countryNameWrite|createChar|cursor|debugPrint|delay|delayMicroseconds|detach|detachInterrupt|digitalRead|digitalWrite|disconnect|display|displayLogos|drawBMP|drawCompass|encryptionType|end|endPacket|endSMS|endTransmission|endWrite|exists|exitValue|fill|find|findUntil|flush|gatewayIP|get|getAsynchronously|getBand|getButton|getCurrentCarrier|getIMEI|getKey|getModifiers|getOemKey|getPINUsed|getResult|getSignalStrength|getSocket|getVoiceCallStatus|getXChange|getYChange|hangCall|height|highByte|home|image|interrupts|isActionDone|isDirectory|isListening|isPIN|isPressed|isValid|keyPressed|keyReleased|keyboardRead|knobRead|leftToRight|line|lineFollowConfig|listen|listenOnLocalhost|loadImage|localIP|lowByte|macAddress|maintain|map|max|messageAvailable|micros|millis|min|mkdir|motorsStop|motorsWrite|mouseDragged|mouseMoved|mousePressed|mouseReleased|move|noAutoscroll|noBlink|noBuffer|noCursor|noDisplay|noFill|noInterrupts|noListenOnLocalhost|noStroke|noTone|onReceive|onRequest|open|openNextFile|overflow|parseCommand|parseFloat|parseInt|parsePacket|pauseMode|peek|pinMode|playFile|playMelody|point|pointTo|position|pow|prepare|press|print|printFirmwareVersion|printVersion|println|process|processInput|pulseIn|put|random|randomSeed|read|readAccelerometer|readBlue|readButton|readBytes|readBytesUntil|readGreen|readJoystickButton|readJoystickSwitch|readJoystickX|readJoystickY|readLightSensor|readMessage|readMicrophone|readNetworks|readRed|readSlider|readString|readStringUntil|readTemperature|ready|rect|release|releaseAll|remoteIP|remoteNumber|remotePort|remove|requestFrom|retrieveCallingNumber|rewindDirectory|rightToLeft|rmdir|robotNameRead|robotNameWrite|run|runAsynchronously|runShellCommand|runShellCommandAsynchronously|running|scanNetworks|scrollDisplayLeft|scrollDisplayRight|seek|sendAnalog|sendDigitalPortPair|sendDigitalPorts|sendString|sendSysex|serialEvent|setBand|setBitOrder|setClockDivider|setCursor|setDNS|setDataMode|setFirmwareVersion|setMode|setPINUsed|setSpeed|setTextSize|setTimeout|shiftIn|shiftOut|shutdown|sin|size|sqrt|startLoop|step|stop|stroke|subnetMask|switchPIN|tan|tempoWrite|text|tone|transfer|tuneWrite|turn|updateIR|userNameRead|userNameWrite|voiceCall|waitContinue|width|write|writeBlue|writeGreen|writeJSON|writeMessage|writeMicroseconds|writeRGB|writeRed|yield)\b/
});
}
});
} as LanguageProto<'arduino'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'arff'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'arff',
grammar: {
'comment': /%.*/,
@ -10,4 +12,4 @@ export default /** @type {import("../types").LanguageProto<'arff'>} */ ({
'number': /\b\d+(?:\.\d+)?\b/,
'punctuation': /[{},]/
}
});
} as LanguageProto<'arff'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'armasm'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'armasm',
alias: 'arm-asm',
grammar: {
@ -48,4 +50,4 @@ export default /** @type {import("../types").LanguageProto<'armasm'>} */ ({
'operator': /<>|<<|>>|&&|\|\||[=!<>/]=?|[+\-*%#?&|^]|:[A-Z]+:/,
'punctuation': /[()[\],]/
}
});
} as LanguageProto<'armasm'>

View File

@ -1,3 +1,5 @@
import type { LanguageProto } from "../types";
/**
* @param {string} lang
* @param {string} [pattern]
@ -18,7 +20,7 @@ function createLanguageString(lang, pattern) {
};
}
export default /** @type {import("../types").LanguageProto<'arturo'>} */ ({
export default {
id: 'arturo',
alias: 'art',
grammar: {
@ -102,4 +104,4 @@ export default /** @type {import("../types").LanguageProto<'arturo'>} */ ({
pattern: /\b(?:false|maybe|true)\b/
}
}
});
} as LanguageProto<'arturo'>

View File

@ -1,6 +1,7 @@
import type { LanguageProto } from "../types";
import { rest } from '../shared/symbols';
export default /** @type {import("../types").LanguageProto<'asciidoc'>} */ ({
export default {
id: 'asciidoc',
alias: 'adoc',
grammar() {
@ -240,4 +241,4 @@ export default /** @type {import("../types").LanguageProto<'asciidoc'>} */ ({
}
});
}
});
} as LanguageProto<'asciidoc'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'asm6502'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'asm6502',
grammar: {
'comment': /;.*/,
@ -29,4 +31,4 @@ export default /** @type {import("../types").LanguageProto<'asm6502'>} */ ({
},
'punctuation': /[(),:]/
}
});
} as LanguageProto<'asm6502'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'asmatmel'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'asmatmel',
grammar: {
'comment': {
@ -43,4 +45,4 @@ export default /** @type {import("../types").LanguageProto<'asmatmel'>} */ ({
'operator': />>=?|<<=?|&[&=]?|\|[\|=]?|[-+*/%^!=<>?]=?/,
'punctuation': /[(),:]/
}
});
} as LanguageProto<'asmatmel'>

View File

@ -1,9 +1,10 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import { rest } from '../shared/symbols';
import csharp from './prism-csharp';
import markup from './prism-markup';
export default /** @type {import("../types").LanguageProto<'aspnet'>} */ ({
export default {
id: 'aspnet',
require: [markup, csharp],
grammar({ extend }) {
@ -64,4 +65,4 @@ export default /** @type {import("../types").LanguageProto<'aspnet'>} */ ({
return aspnet;
}
});
} as LanguageProto<'aspnet'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'autohotkey'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'autohotkey',
grammar() {
// NOTES - follows first-first highlight method, block is locked after highlight, different from SyntaxHl
@ -46,4 +48,4 @@ export default /** @type {import("../types").LanguageProto<'autohotkey'>} */ ({
'punctuation': /[{}[\]():,]/
};
}
});
} as LanguageProto<'autohotkey'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'autoit'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'autoit',
grammar: {
'comment': [
@ -34,4 +36,4 @@ export default /** @type {import("../types").LanguageProto<'autoit'>} */ ({
'operator': /<[=>]?|[-+*\/=&>]=?|[?^]|\b(?:And|Not|Or)\b/i,
'punctuation': /[\[\]().,:]/
}
});
} as LanguageProto<'autoit'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'avisynth'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'avisynth',
alias: 'avs',
grammar() {
@ -195,4 +197,4 @@ export default /** @type {import("../types").LanguageProto<'avisynth'>} */ ({
'punctuation': /[{}\[\]();,.]/
};
}
});
} as LanguageProto<'avisynth'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'avro-idl'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'avro-idl',
alias: 'avdl',
grammar() {
@ -51,4 +53,4 @@ export default /** @type {import("../types").LanguageProto<'avro-idl'>} */ ({
'punctuation': /[()\[\]{}<>.:,;-]/
};
}
});
} as LanguageProto<'avro-idl'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'awk'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'awk',
alias: 'gawk',
grammar: {
@ -31,4 +33,4 @@ export default /** @type {import("../types").LanguageProto<'awk'>} */ ({
'operator': /--|\+\+|!?~|>&|>>|<<|(?:\*\*|[<>!=+\-*/%^])=?|&&|\|[|&]|[?:]/,
'punctuation': /[()[\]{},;]/
}
});
} as LanguageProto<'awk'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'bash'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'bash',
alias: ['sh', 'shell'],
grammar() {
@ -236,4 +238,4 @@ export default /** @type {import("../types").LanguageProto<'bash'>} */ ({
return bash;
}
});
} as LanguageProto<'bash'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'basic'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'basic',
grammar: {
'comment': {
@ -17,4 +19,4 @@ export default /** @type {import("../types").LanguageProto<'basic'>} */ ({
'operator': /<[=>]?|>=?|[+\-*\/^=&]|\b(?:AND|EQV|IMP|NOT|OR|XOR)\b/i,
'punctuation': /[,;:()]/
}
});
} as LanguageProto<'basic'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'batch'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'batch',
grammar() {
const variable = /%%?[~:\w]+%?|!\S+!/;
@ -99,4 +101,4 @@ export default /** @type {import("../types").LanguageProto<'batch'>} */ ({
'punctuation': /[()']/
};
}
});
} as LanguageProto<'batch'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'bbcode'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'bbcode',
alias: 'shortcode',
grammar: {
@ -28,4 +30,4 @@ export default /** @type {import("../types").LanguageProto<'bbcode'>} */ ({
}
}
}
});
} as LanguageProto<'bbcode'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'bbj'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'bbj',
grammar: {
'comment': {
@ -17,4 +19,4 @@ export default /** @type {import("../types").LanguageProto<'bbj'>} */ ({
'operator': /<[=>]?|>=?|[+\-*\/^=&]|\b(?:and|not|or|xor)\b/i,
'punctuation': /[.,;:()]/
}
});
} as LanguageProto<'bbj'>

View File

@ -1,6 +1,8 @@
import type { LanguageProto } from "../types";
// based loosely upon: https://github.com/Azure/bicep/blob/main/src/textmate/bicep.tmlanguage
export default /** @type {import("../types").LanguageProto<'bicep'>} */ ({
export default {
id: 'bicep',
grammar: {
'comment': [
@ -77,4 +79,4 @@ export default /** @type {import("../types").LanguageProto<'bicep'>} */ ({
'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/,
'punctuation': /[{}[\];(),.:]/,
}
});
} as LanguageProto<'bicep'>

View File

@ -1,7 +1,8 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import clike from './prism-clike';
export default /** @type {import("../types").LanguageProto<'birb'>} */ ({
export default {
id: 'birb',
require: clike,
grammar({ extend }) {
@ -31,4 +32,4 @@ export default /** @type {import("../types").LanguageProto<'birb'>} */ ({
return birb;
}
});
} as LanguageProto<'birb'>

View File

@ -1,8 +1,9 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import { rest } from '../shared/symbols';
import c from './prism-c';
export default /** @type {import("../types").LanguageProto<'bison'>} */ ({
export default {
id: 'bison',
require: c,
grammar({ extend, getLanguage }) {
@ -49,4 +50,4 @@ export default /** @type {import("../types").LanguageProto<'bison'>} */ ({
return bison;
}
});
} as LanguageProto<'bison'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'bnf'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'bnf',
alias: 'rbnf',
grammar: {
@ -20,4 +22,4 @@ export default /** @type {import("../types").LanguageProto<'bnf'>} */ ({
},
'operator': /::=|[|()[\]{}*+?]|\.{3}/
}
});
} as LanguageProto<'bnf'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'bqn'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'bqn',
grammar: {
'shebang': {
@ -63,4 +65,4 @@ export default /** @type {import("../types").LanguageProto<'bqn'>} */ ({
},
'punctuation': /[←⇐↩(){}⟨⟩[\]‿·⋄,.;:?]/
}
});
} as LanguageProto<'bqn'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'brainfuck'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'brainfuck',
grammar: {
'pointer': {
@ -20,4 +22,4 @@ export default /** @type {import("../types").LanguageProto<'brainfuck'>} */ ({
'operator': /[.,]/,
'comment': /\S+/
}
});
} as LanguageProto<'brainfuck'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'brightscript'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'brightscript',
grammar: {
'comment': /(?:\brem|').*/i,
@ -42,4 +44,4 @@ export default /** @type {import("../types").LanguageProto<'brightscript'>} */ (
'punctuation': /[.,;()[\]{}]/,
'constant': /\b(?:LINE_NUM)\b/i
}
});
} as LanguageProto<'brightscript'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'bro'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'bro',
grammar: {
@ -37,4 +39,4 @@ export default /** @type {import("../types").LanguageProto<'bro'>} */ ({
'punctuation': /[{}[\];(),.:]/
}
});
} as LanguageProto<'bro'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'bsl'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'bsl',
alias: 'oscript',
grammar() {
@ -76,4 +78,4 @@ export default /** @type {import("../types").LanguageProto<'bsl'>} */ ({
]
};
}
});
} as LanguageProto<'bsl'>

View File

@ -1,7 +1,8 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import clike from './prism-clike';
export default /** @type {import("../types").LanguageProto<'c'>} */ ({
export default {
id: 'c',
require: clike,
optional: 'opencl-extensions',
@ -96,4 +97,4 @@ export default /** @type {import("../types").LanguageProto<'c'>} */ ({
return c;
}
});
} as LanguageProto<'c'>

View File

@ -1,7 +1,8 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import clike from './prism-clike';
export default /** @type {import("../types").LanguageProto<'cfscript'>} */ ({
export default {
id: 'cfscript',
require: clike,
alias: 'cfc',
@ -52,4 +53,4 @@ export default /** @type {import("../types").LanguageProto<'cfscript'>} */ ({
return cfscript;
}
});
} as LanguageProto<'cfscript'>

View File

@ -1,9 +1,10 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import { toArray } from '../shared/util';
import clike from './prism-clike';
import cpp from './prism-cpp';
export default /** @type {import("../types").LanguageProto<'chaiscript'>} */ ({
export default {
id: 'chaiscript',
require: [clike, cpp],
grammar({ extend, getLanguage }) {
@ -72,4 +73,4 @@ export default /** @type {import("../types").LanguageProto<'chaiscript'>} */ ({
return chaiscript;
}
});
} as LanguageProto<'chaiscript'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'cil'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'cil',
grammar: {
'comment': /\/\/.*/,
@ -27,4 +29,4 @@ export default /** @type {import("../types").LanguageProto<'cil'>} */ ({
'punctuation': /[{}[\];(),:=]|IL_[0-9A-Za-z]+/
}
});
} as LanguageProto<'cil'>

View File

@ -1,7 +1,8 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import c from './prism-c';
export default /** @type {import("../types").LanguageProto<'cilkc'>} */ ({
export default {
id: 'cilkc',
require: c,
alias: 'cilk-c',
@ -15,4 +16,4 @@ export default /** @type {import("../types").LanguageProto<'cilkc'>} */ ({
});
return cilkc;
}
});
} as LanguageProto<'cilkc'>

View File

@ -1,7 +1,8 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import cpp from './prism-cpp';
export default /** @type {import("../types").LanguageProto<'cilkcpp'>} */ ({
export default {
id: 'cilkcpp',
require: cpp,
alias: ['cilk-cpp', 'cilk'],
@ -15,4 +16,4 @@ export default /** @type {import("../types").LanguageProto<'cilkcpp'>} */ ({
});
return cilkcpp;
}
});
} as LanguageProto<'cilkcpp'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'clike'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'clike',
grammar: {
'comment': [
@ -31,4 +33,4 @@ export default /** @type {import("../types").LanguageProto<'clike'>} */ ({
'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
'punctuation': /[{}[\];(),.:]/
}
});
} as LanguageProto<'clike'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'clojure'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'clojure',
grammar() {
// Copied from https://github.com/jeluard/prism-clojure
@ -33,4 +35,4 @@ export default /** @type {import("../types").LanguageProto<'clojure'>} */ ({
'punctuation': /[{}\[\](),]/
};
}
});
} as LanguageProto<'clojure'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'cmake'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'cmake',
grammar: {
'comment': /#.*/,
@ -29,4 +31,4 @@ export default /** @type {import("../types").LanguageProto<'cmake'>} */ ({
'function': /\b[a-z_]\w*(?=\s*\()\b/i,
'punctuation': /[()>}]|\$[<{]/
}
});
} as LanguageProto<'cmake'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'cobol'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'cobol',
grammar: {
'comment': {
@ -53,4 +55,4 @@ export default /** @type {import("../types").LanguageProto<'cobol'>} */ ({
],
'punctuation': /[.:,()]/
}
});
} as LanguageProto<'cobol'>

View File

@ -1,7 +1,8 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import javascript from './prism-javascript';
export default /** @type {import("../types").LanguageProto<'coffeescript'>} */ ({
export default {
id: 'coffeescript',
require: javascript,
alias: 'coffee',
@ -101,4 +102,4 @@ export default /** @type {import("../types").LanguageProto<'coffeescript'>} */ (
return coffeescript;
}
});
} as LanguageProto<'coffeescript'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'concurnas'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'concurnas',
alias: 'conc',
grammar: {
@ -57,4 +59,4 @@ export default /** @type {import("../types").LanguageProto<'concurnas'>} */ ({
alias: 'builtin'
}
}
});
} as LanguageProto<'concurnas'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'cooklang'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'cooklang',
grammar() {
// see https://github.com/cooklang/spec/blob/main/EBNF.md
@ -145,4 +147,4 @@ export default /** @type {import("../types").LanguageProto<'cooklang'>} */ ({
}
};
}
});
} as LanguageProto<'cooklang'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'coq'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'coq',
grammar() {
// https://github.com/coq/coq
@ -52,4 +54,4 @@ export default /** @type {import("../types").LanguageProto<'coq'>} */ ({
'punctuation': /\.\(|`\(|@\{|`\{|\{\||\[=|:>|[:.,;(){}\[\]]/
};
}
});
} as LanguageProto<'coq'>

View File

@ -1,7 +1,8 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import c from './prism-c';
export default /** @type {import("../types").LanguageProto<'cpp'>} */ ({
export default {
id: 'cpp',
require: c,
optional: 'opencl-extensions',
@ -111,4 +112,4 @@ export default /** @type {import("../types").LanguageProto<'cpp'>} */ ({
return cpp;
}
});
} as LanguageProto<'cpp'>

View File

@ -1,8 +1,9 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import { toArray } from '../shared/util';
import ruby from './prism-ruby';
export default /** @type {import("../types").LanguageProto<'crystal'>} */ ({
export default {
id: 'crystal',
require: ruby,
grammar({ extend, getLanguage }) {
@ -64,4 +65,4 @@ export default /** @type {import("../types").LanguageProto<'crystal'>} */ ({
return crystal;
}
});
} as LanguageProto<'crystal'>

View File

@ -1,3 +1,4 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import clike from './prism-clike';
@ -40,7 +41,7 @@ function nested(pattern, depthLog2) {
return pattern.replace(/<<self>>/g, '[^\\s\\S]');
}
export default /** @type {import("../types").LanguageProto<'csharp'>} */ ({
export default {
id: 'csharp',
require: clike,
optional: 'xml-doc',
@ -381,4 +382,4 @@ export default /** @type {import("../types").LanguageProto<'csharp'>} */ ({
return csharp;
}
});
} as LanguageProto<'csharp'>

View File

@ -1,8 +1,9 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import csharp from './prism-csharp';
import markup from './prism-markup';
export default /** @type {import("../types").LanguageProto<'cshtml'>} */ ({
export default {
id: 'cshtml',
require: [markup, csharp],
alias: 'razor',
@ -208,4 +209,4 @@ export default /** @type {import("../types").LanguageProto<'cshtml'>} */ ({
return cshtml;
}
});
} as LanguageProto<'cshtml'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'csp'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'csp',
grammar() {
/**
@ -75,4 +77,4 @@ export default /** @type {import("../types").LanguageProto<'csp'>} */ ({
'punctuation': /;/
};
}
});
} as LanguageProto<'csp'>

View File

@ -1,6 +1,7 @@
import type { LanguageProto } from "../types";
import cssSelector from './prism-css-selector';
export default /** @type {import("../types").LanguageProto<'css-extras'>} */ ({
export default {
id: 'css-extras',
require: cssSelector,
grammar() {
@ -46,4 +47,4 @@ export default /** @type {import("../types").LanguageProto<'css-extras'>} */ ({
'number': number
};
}
});
} as LanguageProto<'css-extras'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'css-selector'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'css-selector',
grammar() {
const string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
@ -62,4 +64,4 @@ export default /** @type {import("../types").LanguageProto<'css-selector'>} */ (
'punctuation': /[(),]/,
};
}
});
} as LanguageProto<'css-selector'>

View File

@ -1,7 +1,8 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import { rest } from '../shared/symbols';
export default /** @type {import("../types").LanguageProto<'css'>} */ ({
export default {
id: 'css',
optional: 'css-extras',
grammar({ getOptionalLanguage }) {
@ -71,4 +72,4 @@ export default /** @type {import("../types").LanguageProto<'css'>} */ ({
return css;
}
});
} as LanguageProto<'css'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'csv'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'csv',
grammar() {
// https://tools.ietf.org/html/rfc4180
@ -8,4 +10,4 @@ export default /** @type {import("../types").LanguageProto<'csv'>} */ ({
'punctuation': /,/
};
}
});
} as LanguageProto<'csv'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'cue'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'cue',
grammar() {
// https://cuelang.org/docs/references/spec/
@ -80,4 +82,4 @@ export default /** @type {import("../types").LanguageProto<'cue'>} */ ({
'punctuation': /[()[\]{},.:]/
};
}
});
} as LanguageProto<'cue'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'cypher'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'cypher',
grammar: {
// https://neo4j.com/docs/cypher-manual/current/syntax/comments/
@ -36,4 +38,4 @@ export default /** @type {import("../types").LanguageProto<'cypher'>} */ ({
'operator': /:|<--?|--?>?|<>|=~?|[<>]=?|[+*/%^|]|\.\.\.?/,
'punctuation': /[()[\]{},;.]/
}
});
} as LanguageProto<'cypher'>

View File

@ -1,7 +1,8 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import clike from './prism-clike';
export default /** @type {import("../types").LanguageProto<'d'>} */ ({
export default {
id: 'd',
require: clike,
grammar({ extend }) {
@ -92,4 +93,4 @@ export default /** @type {import("../types").LanguageProto<'d'>} */ ({
return d;
}
});
} as LanguageProto<'d'>

View File

@ -1,7 +1,8 @@
import type { LanguageProto } from "../types";
import { insertBefore } from '../shared/language-util';
import clike from './prism-clike';
export default /** @type {import("../types").LanguageProto<'dart'>} */ ({
export default {
id: 'dart',
require: clike,
grammar({ extend }) {
@ -85,4 +86,4 @@ export default /** @type {import("../types").LanguageProto<'dart'>} */ ({
return dart;
}
});
} as LanguageProto<'dart'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'dataweave'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'dataweave',
grammar: {
'url': /\b[A-Za-z]+:\/\/[\w/:.?=&-]+|\burn:[\w:.?=&-]+/,
@ -38,4 +40,4 @@ export default /** @type {import("../types").LanguageProto<'dataweave'>} */ ({
'operator': /<<|>>|->|[<>~=]=?|!=|--?-?|\+\+?|!|\?/,
'boolean': /\b(?:false|true)\b/,
}
});
} as LanguageProto<'dataweave'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'dax'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'dax',
grammar: {
'comment': {
@ -27,4 +29,4 @@ export default /** @type {import("../types").LanguageProto<'dax'>} */ ({
'operator': /:=|[-+*\/=^]|&&?|\|\||<(?:=>?|<|>)?|>[>=]?|\b(?:IN|NOT)\b/i,
'punctuation': /[;\[\](){}`,.]/
}
});
} as LanguageProto<'dax'>

View File

@ -1,7 +1,9 @@
import type { LanguageProto } from "../types";
// ABNF grammar:
// https://github.com/dhall-lang/dhall-lang/blob/master/standard/dhall.abnf
export default /** @type {import("../types").LanguageProto<'dhall'>} */ ({
export default {
id: 'dhall',
grammar: {
// Multi-line comments can be nested. E.g. {- foo {- bar -} -}
@ -67,4 +69,4 @@ export default /** @type {import("../types").LanguageProto<'dhall'>} */ ({
// we'll just assume that every capital word left is a type name
'class-name': /\b[A-Z]\w*\b/
}
});
} as LanguageProto<'dhall'>

View File

@ -1,3 +1,5 @@
import type { LanguageProto } from "../types";
/**
* A map from the name of a block to its line prefix.
*/
@ -10,7 +12,7 @@ export const PREFIXES = {
'diff': '!',
};
export default /** @type {import("../types").LanguageProto<'diff'>} */ ({
export default {
id: 'diff',
grammar() {
/** @type {import("../types").Grammar} */
@ -55,4 +57,4 @@ export default /** @type {import("../types").LanguageProto<'diff'>} */ ({
return diff;
}
});
} as LanguageProto<'diff'>

View File

@ -1,3 +1,4 @@
import type { LanguageProto } from "../types";
import { embeddedIn } from '../shared/languages/templating';
import { tokenize } from '../shared/symbols';
import markup from './prism-markup';
@ -5,7 +6,7 @@ import markup from './prism-markup';
// Django/Jinja2 syntax definition for Prism.js <http://prismjs.com> syntax highlighter.
// Mostly it works OK but can paint code incorrectly on complex html/template tag combinations.
export default /** @type {import("../types").LanguageProto<'django'>} */ ({
export default {
id: 'django',
require: markup,
alias: 'jinja2',
@ -48,4 +49,4 @@ export default /** @type {import("../types").LanguageProto<'django'>} */ ({
},
[tokenize]: embeddedIn('markup')
}
});
} as LanguageProto<'django'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'dns-zone-file'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'dns-zone-file',
alias: 'dns-zone',
grammar: {
@ -32,4 +34,4 @@ export default /** @type {import("../types").LanguageProto<'dns-zone-file'>} */
},
'punctuation': /[()]/
}
});
} as LanguageProto<'dns-zone-file'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'docker'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'docker',
alias: 'dockerfile',
grammar() {
@ -95,4 +97,4 @@ export default /** @type {import("../types").LanguageProto<'docker'>} */ ({
'comment': commentRule
};
}
});
} as LanguageProto<'docker'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'dot'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'dot',
alias: 'gv',
grammar() {
@ -74,4 +76,4 @@ export default /** @type {import("../types").LanguageProto<'dot'>} */ ({
'punctuation': /[\[\]{};,]/
};
}
});
} as LanguageProto<'dot'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'ebnf'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'ebnf',
grammar: {
'comment': /\(\*[\s\S]*?\*\)/,
@ -22,4 +24,4 @@ export default /** @type {import("../types").LanguageProto<'ebnf'>} */ ({
'punctuation': /\([:/]|[:/]\)|[.,;()[\]{}]/,
'operator': /[-=|*/!]/
}
});
} as LanguageProto<'ebnf'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'editorconfig'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'editorconfig',
grammar: {
// https://editorconfig-specification.readthedocs.io
@ -26,4 +28,4 @@ export default /** @type {import("../types").LanguageProto<'editorconfig'>} */ (
}
}
}
});
} as LanguageProto<'editorconfig'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'eiffel'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'eiffel',
grammar: {
'comment': /--.*/,
@ -34,4 +36,4 @@ export default /** @type {import("../types").LanguageProto<'eiffel'>} */ ({
'punctuation': /:=|<<|>>|\(\||\|\)|->|\.(?=\w)|[{}[\];(),:?]/,
'operator': /\\\\|\|\.\.\||\.\.|\/[~\/=]?|[><]=?|[-+*^=~]/
}
});
} as LanguageProto<'eiffel'>

View File

@ -1,9 +1,10 @@
import type { LanguageProto } from "../types";
import { embeddedIn } from '../shared/languages/templating';
import { tokenize } from '../shared/symbols';
import javascript from './prism-javascript';
import markup from './prism-markup';
export default /** @type {import("../types").LanguageProto<'ejs'>} */ ({
export default {
id: 'ejs',
require: [javascript, markup],
alias: 'eta',
@ -32,4 +33,4 @@ export default /** @type {import("../types").LanguageProto<'ejs'>} */ ({
},
[tokenize]: embeddedIn('markup')
}
});
} as LanguageProto<'ejs'>

View File

@ -1,6 +1,7 @@
import type { LanguageProto } from "../types";
import { rest } from '../shared/symbols';
export default /** @type {import("../types").LanguageProto<'elixir'>} */ ({
export default {
id: 'elixir',
grammar() {
const stringInside = {
@ -94,4 +95,4 @@ export default /** @type {import("../types").LanguageProto<'elixir'>} */ ({
'punctuation': /<<|>>|[.,%\[\]{}()]/
};
}
});
} as LanguageProto<'elixir'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'elm'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'elm',
grammar: {
'comment': /--.*|\{-[\s\S]*?-\}/,
@ -45,4 +47,4 @@ export default /** @type {import("../types").LanguageProto<'elm'>} */ ({
'constant': /\b(?:[A-Z]\w*\.)*[A-Z]\w*\b/,
'punctuation': /[{}[\]|(),.:]/
}
});
} as LanguageProto<'elm'>

View File

@ -1,9 +1,10 @@
import type { LanguageProto } from "../types";
import { embeddedIn } from '../shared/languages/templating';
import { tokenize } from '../shared/symbols';
import markup from './prism-markup';
import ruby from './prism-ruby';
export default /** @type {import("../types").LanguageProto<'erb'>} */ ({
export default {
id: 'erb',
require: [ruby, markup],
grammar: {
@ -23,4 +24,4 @@ export default /** @type {import("../types").LanguageProto<'erb'>} */ ({
},
[tokenize]: embeddedIn('markup')
}
});
} as LanguageProto<'erb'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'erlang'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'erlang',
grammar: {
'comment': /%.+/,
@ -44,4 +46,4 @@ export default /** @type {import("../types").LanguageProto<'erlang'>} */ ({
'punctuation': /[()[\]{}:;,.#|]|<<|>>/
}
});
} as LanguageProto<'erlang'>

View File

@ -1,9 +1,10 @@
import type { LanguageProto } from "../types";
import { embeddedIn } from '../shared/languages/templating';
import { tokenize } from '../shared/symbols';
import lua from './prism-lua';
import markup from './prism-markup';
export default /** @type {import("../types").LanguageProto<'etlua'>} */ ({
export default {
id: 'etlua',
require: [lua, markup],
grammar: {
@ -22,4 +23,4 @@ export default /** @type {import("../types").LanguageProto<'etlua'>} */ ({
},
[tokenize]: embeddedIn('markup')
}
});
} as LanguageProto<'etlua'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'excel-formula'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'excel-formula',
alias: ['xlsx', 'xls'],
grammar: {
@ -65,4 +67,4 @@ export default /** @type {import("../types").LanguageProto<'excel-formula'>} */
'operator': /[-+*/^%=&,]|<[=>]?|>=?/,
'punctuation': /[[\]();{}|]/
}
});
} as LanguageProto<'excel-formula'>

View File

@ -1,6 +1,7 @@
import type { LanguageProto } from "../types";
import { regexEscape } from '../shared/util';
export default /** @type {import("../types").LanguageProto<'factor'>} */ ({
export default {
id: 'factor',
grammar() {
/**
@ -385,4 +386,4 @@ export default /** @type {import("../types").LanguageProto<'factor'>} */ ({
}
};
}
});
} as LanguageProto<'factor'>

View File

@ -1,4 +1,6 @@
export default /** @type {import("../types").LanguageProto<'false'>} */ ({
import type { LanguageProto } from "../types";
export default {
id: 'false',
grammar() {
/**
@ -32,4 +34,4 @@ export default /** @type {import("../types").LanguageProto<'false'>} */ ({
}
};
}
});
} as LanguageProto<'false'>

Some files were not shown because too many files have changed in this diff Show More