highlight-ts
Version:
Highlight.JS in TypeScript (and ES6).
84 lines (83 loc) • 3.2 kB
TypeScript
export declare type LanguageName = string;
export declare type StringRegExp = string | RegExp;
export declare type SyntaxDef = Partial<FullSyntaxDef>;
export declare type SyntaxDefOrRef = SyntaxDef | 'self';
export declare type KeywordsDef = string | KeywordsGroupDef;
export declare type KeywordsGroupDef = Partial<Record<KeywordGroup, string>>;
export interface LanguageDef extends SyntaxDef {
name: LanguageName;
aliases?: LanguageName[];
case_insensitive?: boolean;
}
export interface FullSyntaxDef {
className: string;
begin: StringRegExp;
end: StringRegExp;
beginKeywords: string;
endsWithParent: boolean;
endsParent: boolean;
lexemes: StringRegExp;
keywords: KeywordsDef;
illegal: StringRegExp;
excludeBegin: boolean;
excludeEnd: boolean;
returnBegin: boolean;
returnEnd: boolean;
contains: SyntaxDefOrRef[];
starts: SyntaxDef;
variants: SyntaxDef[];
subLanguage: LanguageName | LanguageName[];
skip: boolean;
relevance: number;
}
export declare type CompiledKeywords = Partial<Record<KeywordGroup, [string, number]>>;
export interface CompiledSyntaxDef {
className?: string;
keywords?: CompiledKeywords;
contains: CompiledSyntaxDef[];
terminators: RegExp;
beginRe?: RegExp;
endRe?: RegExp;
lexemesRe: RegExp;
illegalRe?: RegExp;
parent?: CompiledSyntaxDef;
starts?: CompiledSyntaxDef;
endsParent?: true;
endsWithParent?: true;
skip?: true;
excludeBegin?: true;
excludeEnd?: true;
returnBegin?: true;
returnEnd?: true;
relevance: number;
subLanguage?: LanguageName[];
}
export interface CompiledLanguageDef extends CompiledSyntaxDef {
case_insensitive?: true;
}
export interface Result<Output> {
language: LanguageName;
relevance: number;
value: Output;
second_best?: Result<Output>;
top?: CompiledLanguageDef;
}
export interface Renderer<Output> {
text(chunk: string): Output;
wrap(className: string, chunk: Output): Output;
join(chunks: Output[]): Output;
}
export interface Options {
classPrefix: string;
tabReplace?: string;
useBr: boolean;
languages?: LanguageName[];
}
export declare type KeywordGroup = KeywordGroupGeneral | KeywordGroupMeta | KeywordGroupTagsAttrsConfs | KeywordGroupMarkup | KeywordGroupStyles | KeywordGroupTemplates | KeywordGroupDiff | '_';
export declare type KeywordGroupGeneral = 'keyword' | 'built_in' | 'type' | 'literal' | 'number' | 'regexp' | 'string' | 'subst' | 'symbol' | 'class' | 'function' | 'title' | 'params';
export declare type KeywordGroupMeta = 'comment' | 'doctag' | 'meta' | 'meta-keyword' | 'meta-string';
export declare type KeywordGroupTagsAttrsConfs = 'section' | 'tag' | 'name' | 'builtin-name' | 'attr' | 'attribute' | 'variable';
export declare type KeywordGroupMarkup = 'bullet' | 'code' | 'emphasis' | 'strong' | 'formula' | 'link' | 'quote';
export declare type KeywordGroupStyles = 'selector-tag' | 'selector-id' | 'selector-class' | 'selector-attr' | 'selector-pseudo';
export declare type KeywordGroupTemplates = 'template-tag' | 'template-variable';
export declare type KeywordGroupDiff = 'addition' | 'deletion';