From 2382d22067c346c9f9e2a586a65a74f33c3a8401 Mon Sep 17 00:00:00 2001 From: Jeremy Hull Date: Sat, 6 Sep 2014 19:42:10 -0700 Subject: [PATCH] Add definition for latest version of highlightjs --- highlightjs/highlightjs.d.ts | 125 +++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 highlightjs/highlightjs.d.ts diff --git a/highlightjs/highlightjs.d.ts b/highlightjs/highlightjs.d.ts new file mode 100644 index 000000000..a4500bd95 --- /dev/null +++ b/highlightjs/highlightjs.d.ts @@ -0,0 +1,125 @@ +// Type definitions for highlight.js v8.2.0 +// Project: https://github.com/isagalaev/highlight.js +// Definitions by: Niklas Mollenhauer , Jeremy Hull +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "highlight.js" +{ + module hljs + { + export function highlight( + name: string, + value: string, + ignore_illegals?: boolean, + continuation?: boolean) : IHighlightResult + export function highlightAuto( + value: string, + languageSubset?: string[]) : IAutoHighlightResult + + export function fixMarkup(value: string) : string; + + export function highlightBlock(block: Node) : void; + + export function configure(options: IOptions): void; + + export function initHighlighting(): void; + export function initHighlightingOnLoad(): void; + + export function registerLanguage( + name: string, + language: IModeBase): void; + export function listLanguages(): string[]; + export function getLanguage(name: string): IMode; + + export function inherit(parent: Object, obj: Object): Object; + + // Common regexps + export var IDENT_RE: string; + export var UNDERSCORE_IDENT_RE: string; + export var NUMBER_RE: string; + export var C_NUMBER_RE: string; + export var BINARY_NUMBER_RE: string; + export var RE_STARTERS_RE: string; + + // Common modes + export var BACKSLASH_ESCAPE : IMode; + export var APOS_STRING_MODE : IMode; + export var QUOTE_STRING_MODE : IMode; + export var PHRASAL_WORDS_MODE : IMode; + export var C_LINE_COMMENT_MODE : IMode; + export var C_BLOCK_COMMENT_MODE : IMode; + export var HASH_COMMENT_MODE : IMode; + export var NUMBER_MODE : IMode; + export var C_NUMBER_MODE : IMode; + export var BINARY_NUMBER_MODE : IMode; + export var CSS_NUMBER_MODE : IMode; + export var REGEX_MODE : IMode; + export var TITLE_MODE : IMode; + export var UNDERSCORE_TITLE_MODE : IMode; + + export interface IHighlightResult + { + relevance: number; + language: string; + top: ICompiledMode; + value: string; + } + + export interface IAutoHighlightResult extends IHighlightResult + { + second_best?: IAutoHighlightResult; + } + + // Reference: + // https://github.com/isagalaev/highlight.js/blob/master/docs/reference.rst + export interface IModeBase + { + className?: string; + aliases?: string[]; + begin: string; + end?: string; + case_insensitive?: boolean; + beginKeyword?: string; + endsWithParent?: boolean; + lexems?: string; + illegal?: string; + excludeBegin?: boolean; + excludeEnd?: boolean; + returnBegin?: boolean; + returnEnd?: boolean; + starts?: string; + subLanguage?: string; + subLanguageMode?: string; + relevance?: number; + variants?: IMode[]; + } + + export interface IMode extends IModeBase + { + keywords?: string; + contains?: IMode[]; + } + + export interface ICompiledMode extends IModeBase + { + compiled: boolean; + contains?: ICompiledMode[]; + keywords?: Object[]; + beginRe: RegExp; + endRe?: RegExp; + lexemesRe?: RegExp; + illegalRe?: RegExp; + terminators: RegExp; + terminator_end?: string; + } + + export interface IOptions + { + classPrefix?: string; + tabReplace?: string; + useBR?: boolean; + languages?: string[]; + } + } + export = hljs; +}