feat: add types for refractor

This commit is contained in:
Ifiok Jr
2019-04-14 12:42:16 +01:00
parent 6a5529e838
commit ab040c4ea5
181 changed files with 703 additions and 0 deletions
+145
View File
@@ -0,0 +1,145 @@
import * as Prism from 'prismjs';
export interface RefractorSyntax {
displayName: string;
aliases: string[];
(prism: typeof Prism): void;
}
export namespace AST {
namespace Unist {
interface Node {
type: string;
}
interface Parent extends Node {
children: RefractorNode[];
}
interface Text extends Node {
value: string;
}
}
interface Properties {
className?: string[];
[key: string]: any;
}
interface Element extends Unist.Parent {
type: 'element';
tagName: string;
properties: Properties;
}
interface Text extends Unist.Text {
type: 'text';
}
}
export type RefractorNode = AST.Element | AST.Text;
/**
* Register a syntax. Needed if you’re using refractor/core.js.
*
* ```ts
* import refractor = require('refractor/core')
* import markdown = require('refractor/lang/markdown')
*
* refractor.register(markdown)
* console.log(refractor.highlight('*Emphasis*', 'markdown'))
*
* // => [ { type: 'element', tagName: 'span', properties: [Object], children: [Array] } ]
* ```
*
* @param syntax
*/
export function register(syntax: RefractorSyntax): void;
/**
* Parse value (string) according to the language (name or alias) syntax.
*
* @returns Virtual nodes representing the highlighted value (Array.<Node>).
*
* ```ts
* import refractor = require('refractor/core')
* console.log(refractor.highlight('em { color: red }', 'css'))
* ```
*
* Yields:
*
* ```
* [
* { type: 'element',
* tagName: 'span',
* properties: [Object],
* children: [Array] },
* { type: 'text', value: ' ' },
* // ...
* { type: 'text', value: ' red ' },
* { type: 'element',
* tagName: 'span',
* properties: [Object],
* children: [Array] }
* ]
* ```
*/
export function highlight(value: string, name: string): RefractorNode[];
/**
* Check if a language (name or alias) is registered.
*
* ```ts
* import refractor = require('refractor/core')
* import markdown = require('refractor/lang/markdown')
*
* console.log(registered('markdown'))
*
* register(markdown)
*
* console.log(registered('markdown'))
*
* // => true | false
* ```
*/
export function registered(name: string): boolean;
/**
* List all registered languages (names and aliases).
*
* ```ts
* import refractor = require('refractor/core')
* import markdown = require('refractor/lang/markdown')
*
* console.log(refractor.listLanguages())
*
* refractor.register(markdown)
*
* console.log(refractor.listLanguages())
* ```
*
* Yields:
*
* ```
* [ 'markup',
* 'xml',
* 'html',
* 'mathml',
* 'svg',
* 'css',
* 'clike',
* 'javascript',
* 'js' ]
* [ 'markup',
* 'xml',
* 'html',
* 'mathml',
* 'svg',
* 'css',
* 'clike',
* 'javascript',
* 'js',
* 'markdown' ]
* ```
*/
export function listLanguages(): string[];
+8
View File
@@ -0,0 +1,8 @@
// Type definitions for refractor 2.8
// Project: https://github.com/wooorm/refractor#readme
// Definitions by: Ifiok Jr. <https://github.com/ifiokjr>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import refractor = require('./core');
export = refractor;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;
+3
View File
@@ -0,0 +1,3 @@
import { RefractorSyntax } from '../core';
declare const lang: RefractorSyntax;
export = lang;

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