Merge pull request #1036 from nikeee/highlight.js

Add highlight.js definitions
This commit is contained in:
Boris Yankov
2013-09-11 07:35:17 -07:00
3 changed files with 104 additions and 1 deletions
+2 -1
View File
@@ -82,6 +82,7 @@ List of Definitions
* [Hammer.js](http://eightmedia.github.com/hammer.js/) (by [Boris Yankov](https://github.com/borisyankov))
* [Handlebars](http://handlebarsjs.com/) (by [Boris Yankov](https://github.com/borisyankov))
* [Highcharts](http://www.highcharts.com/) (by [damianog](https://github.com/damianog))
* [highlight.js](https://github.com/isagalaev/highlight.js) (by [Niklas Mollenhauer](https://github.com/nikeee))
* [History.js](https://github.com/browserstate/history.js) (by [Boris Yankov](https://github.com/borisyankov))
* [Humane.js](http://wavded.github.com/humane-js/) (by [John Vrbanac](https://github.com/jmvrbanac))
* [i18next](http://i18next.com/) (by [Maarten Docter](https://github.com/mdocter))
@@ -230,4 +231,4 @@ Requested Definitions
* [java](https://github.com/nearinfinity/node-java)
* [SVG.js](http://www.svgjs.com/)
In addition you can find the [updated open requests that you can contribute here](https://github.com/borisyankov/DefinitelyTyped/issues?labels=request&page=1&state=open)
In addition you can find the [updated open requests that you can contribute here](https://github.com/borisyankov/DefinitelyTyped/issues?labels=request&page=1&state=open)
+18
View File
@@ -0,0 +1,18 @@
/*
highlight.js definition by Niklas Mollenhauer
Last Update: 10.09.2013
Source Code: https://github.com/isagalaev/highlight.js
Project Page: http://softwaremaniacs.org/soft/highlight/en/
*/
/// <reference path="highlight.js.d.ts" />
import hljs = require("highlight.js");
var code = "using System;\npublic class Test\n{\npublic static void Main()\n{\n// your code goes here\n}\n}";
var lang = "cs";
hljs.tabReplace = " "; // 4 spaces
var hl = hljs.highlight(lang, code).value;
hl = hljs.highlightAuto(code).value;
+84
View File
@@ -0,0 +1,84 @@
/*
highlight.js definition by Niklas Mollenhauer
Last Update: 10.09.2013
Source Code: https://github.com/isagalaev/highlight.js
Project Page: http://softwaremaniacs.org/soft/highlight/en/
*/
declare module "highlight.js"
{
module hljs
{
export var LANGUAGES: { [name: string] : any; };
export function blockText(block: Node, ignoreNewLines: boolean) : string;
export function blockLanguage(block: Node) : string;
export function highlight(language_name: string, value: string) : IHighlightResult
export function highlightAuto(text: string) : IHighlightResult
export function fixMarkup(value: string, tabReplace: boolean, useBR: boolean) : string;
export function highlightBlock(block: Node, tabReplace?: boolean, useBR?: boolean) : void;
export function initHighlighting(): void;
export function initHighlightingOnLoad(): void;
export var tabReplace : string;
// 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 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 interface IHighlightResult
{
relevance: number;
keyword_count: number;
value: string;
}
export interface IAutoHighlightResult extends IHighlightResult
{
language: string;
second_best?: IAutoHighlightResult;
}
// Reference:
// https://github.com/isagalaev/highlight.js/blob/master/docs/reference.rst
export interface IMode
{
className?: string;
begin: string;
end?: string;
beginWithKeyword?: boolean;
endsWithParent?: boolean;
lexems?: string;
keywords?: Object;
illegal?: string;
excludeBegin?: boolean;
excludeEnd?: boolean;
returnBegin?: boolean;
returnEnd?: boolean;
contains?: IMode[];
starts?: string;
subLanguage?: string;
relevance?: number;
}
}
export = hljs;
}