mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
added a global marked variable, missing settings, and comments
the JSDoc comments aren't complete but it's a start
This commit is contained in:
parent
e3e0318543
commit
d93cab373e
@ -2,18 +2,37 @@
|
||||
|
||||
import marked = require('marked');
|
||||
|
||||
marked.setOptions({
|
||||
var options: MarkedOptions = {
|
||||
gfm: true,
|
||||
tables: true,
|
||||
breaks: false,
|
||||
pedantic: false,
|
||||
sanitize: true,
|
||||
highlight: function (code, lang) {
|
||||
}
|
||||
});
|
||||
console.log(marked('i am using __markdown__.'));
|
||||
smartLsts: true,
|
||||
silent: false,
|
||||
highlight: function (code: string, lang: string) {
|
||||
return '';
|
||||
},
|
||||
langPrefix: 'lang-',
|
||||
smartypants: false
|
||||
};
|
||||
|
||||
var text = 'something',
|
||||
options = {};
|
||||
function callback() {
|
||||
console.log('callback called');
|
||||
}
|
||||
|
||||
marked.setOptions(options);
|
||||
|
||||
console.log(marked('i am using __markdown__.'));
|
||||
console.log(marked('i am using __markdown__.', options));
|
||||
console.log(marked('i am using __markdown__.', callback));
|
||||
console.log(marked('i am using __markdown__.', options, callback));
|
||||
|
||||
console.log(marked.parse('i am using __markdown__.'));
|
||||
console.log(marked.parse('i am using __markdown__.', options));
|
||||
console.log(marked.parse('i am using __markdown__.', callback));
|
||||
console.log(marked.parse('i am using __markdown__.', options, callback));
|
||||
|
||||
var text = 'something';
|
||||
var tokens = marked.lexer(text, options);
|
||||
console.log(marked.parser(tokens));
|
||||
console.log(marked.parser(tokens));
|
||||
129
marked/marked.d.ts
vendored
129
marked/marked.d.ts
vendored
@ -4,23 +4,118 @@
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
interface MarkedStatic {
|
||||
/**
|
||||
* Compiles markdown to HTML.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
|
||||
* @return String of compiled HTML
|
||||
*/
|
||||
(src: string, callback: Function): string;
|
||||
|
||||
/**
|
||||
* Compiles markdown to HTML.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Hash of options
|
||||
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
|
||||
* @return String of compiled HTML
|
||||
*/
|
||||
(src: string, options?: MarkedOptions, callback?: Function): string;
|
||||
|
||||
/**
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Hash of options
|
||||
*/
|
||||
lexer(src: string, options?: MarkedOptions): any[];
|
||||
|
||||
/**
|
||||
* Compiles markdown to HTML.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
|
||||
* @return String of compiled HTML
|
||||
*/
|
||||
parse(src: string, callback: Function): string;
|
||||
|
||||
/**
|
||||
* Compiles markdown to HTML.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Hash of options
|
||||
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
|
||||
* @return String of compiled HTML
|
||||
*/
|
||||
parse(src: string, options?: MarkedOptions, callback?: Function): string;
|
||||
|
||||
/**
|
||||
* @param options Hash of options
|
||||
*/
|
||||
parser(src: any[], options?: MarkedOptions): string;
|
||||
|
||||
/**
|
||||
* Sets the default options.
|
||||
*
|
||||
* @param options Hash of options
|
||||
*/
|
||||
setOptions(options: MarkedOptions): void;
|
||||
}
|
||||
|
||||
interface MarkedOptions {
|
||||
/**
|
||||
* Enable GitHub flavored markdown.
|
||||
*/
|
||||
gfm?: boolean;
|
||||
|
||||
/**
|
||||
* Enable GFM tables. This option requires the gfm option to be true.
|
||||
*/
|
||||
tables?: boolean;
|
||||
|
||||
/**
|
||||
* Enable GFM line breaks. This option requires the gfm option to be true.
|
||||
*/
|
||||
breaks?: boolean;
|
||||
|
||||
/**
|
||||
* Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
|
||||
*/
|
||||
pedantic?: boolean;
|
||||
|
||||
/**
|
||||
* Sanitize the output. Ignore any HTML that has been input.
|
||||
*/
|
||||
sanitize?: boolean;
|
||||
|
||||
/**
|
||||
* Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic.
|
||||
*/
|
||||
smartLists?: boolean;
|
||||
|
||||
/**
|
||||
* Shows an HTML error message when rendering fails.
|
||||
*/
|
||||
silent?: boolean;
|
||||
|
||||
/**
|
||||
* A function to highlight code blocks. The function takes three arguments: code, lang, and callback.
|
||||
*/
|
||||
highlight? (code: string, lang: string, callback?: Function): string;
|
||||
|
||||
/**
|
||||
* Set the prefix for code block classes.
|
||||
*/
|
||||
langPrefix?: string;
|
||||
|
||||
/**
|
||||
* Use "smart" typograhic punctuation for things like quotes and dashes.
|
||||
*/
|
||||
smartypants?: boolean;
|
||||
}
|
||||
|
||||
declare module "marked" {
|
||||
function marked(src: string, opt?: Options): string;
|
||||
module marked {
|
||||
export function lexer(src: string, opt?: Options): any[];
|
||||
export function parser(src: any[], opt?: Options): string;
|
||||
export function parse(src: string, opt?: Options): string;
|
||||
export function setOptions(opt: Options): void;
|
||||
}
|
||||
|
||||
export = marked;
|
||||
export = marked;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
gfm?: boolean;
|
||||
tables?: boolean;
|
||||
breaks?: boolean;
|
||||
pedantic?: boolean;
|
||||
sanitize?: boolean;
|
||||
highlight?: any;
|
||||
}
|
||||
declare var marked: MarkedStatic;
|
||||
Loading…
Reference in New Issue
Block a user