1 // Type definitions for Marked 0.3
2 // Project: https://github.com/chjj/marked
3 // Definitions by: William Orr <https://github.com/worr>
4 // BendingBender <https://github.com/BendingBender>
5 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7 declare var marked : marked.markedStatic;
9 export as namespace marked;
13 declare namespace marked {
15 * Compiles markdown to HTML.
17 * @param src String of markdown source to be compiled
18 * @param callback Function called when the markdownString has been fully parsed when using async highlighting
19 * @return String of compiled HTML
21 function markedStatic(src: string, callback: (error: any | undefined, parseResult: string) => void): string;
24 * Compiles markdown to HTML.
26 * @param src String of markdown source to be compiled
27 * @param options Hash of options
28 * @param callback Function called when the markdownString has been fully parsed when using async highlighting
29 * @return String of compiled HTML
31 function markedStatic(src: string, options?: marked.MarkedOptions, callback?: (error: any | undefined, parseResult: string) => void): string;
34 * @param src String of markdown source to be compiled
35 * @param options Hash of options
37 function lexer(src: string, options?: MarkedOptions): TokensList;
40 * Compiles markdown to HTML.
42 * @param src String of markdown source to be compiled
43 * @param callback Function called when the markdownString has been fully parsed when using async highlighting
44 * @return String of compiled HTML
46 function parse(src: string, callback: (error: any | undefined, parseResult: string) => void): string;
49 * Compiles markdown to HTML.
51 * @param src String of markdown source to be compiled
52 * @param options Hash of options
53 * @param callback Function called when the markdownString has been fully parsed when using async highlighting
54 * @return String of compiled HTML
56 function parse(src: string, options?: MarkedOptions, callback?: (error: any | undefined, parseResult: string) => void): string;
59 * @param src Tokenized source as array of tokens
60 * @param options Hash of options
62 function parser(src: TokensList, options?: MarkedOptions): string;
65 * Sets the default options.
67 * @param options Hash of options
69 function setOptions(options: MarkedOptions): typeof marked;
72 constructor(options?: MarkedOptions);
73 code(code: string, language: string, isEscaped: boolean): string;
74 blockquote(quote: string): string;
75 html(html: string): string;
76 heading(text: string, level: number, raw: string): string;
78 list(body: string, ordered: boolean): string;
79 listitem(text: string): string;
80 paragraph(text: string): string;
81 table(header: string, body: string): string;
82 tablerow(content: string): string;
83 tablecell(content: string, flags: {
85 align: 'center' | 'left' | 'right' | null;
87 strong(text: string): string;
88 em(text: string): string;
89 codespan(code: string): string;
91 del(text: string): string;
92 link(href: string, title: string, text: string): string;
93 image(href: string, title: string, text: string): string;
94 text(text: string): string;
100 constructor(options?: MarkedOptions);
101 lex(src: string): TokensList;
105 [ruleName: string]: RegExp | Rules;
108 type TokensList = Token[] & {
110 [key: string]: { href: string; title: string; }
120 | Tokens.BlockquoteStart
121 | Tokens.BlockquoteEnd
123 | Tokens.LooseItemStart
124 | Tokens.ListItemStart
151 align: Array<'center' | 'left' | 'right' | null>;
159 interface BlockquoteStart {
160 type: 'blockquote_start';
163 interface BlockquoteEnd {
164 type: 'blockquote_end';
167 interface ListStart {
172 interface LooseItemStart {
173 type: 'loose_item_start';
176 interface ListItemStart {
177 type: 'list_item_start';
180 interface ListItemEnd {
181 type: 'list_item_end';
188 interface Paragraph {
206 interface MarkedOptions {
208 * Type: object Default: new Renderer()
210 * An object containing functions to render tokens to HTML.
215 * Enable GitHub flavored markdown.
220 * Enable GFM tables. This option requires the gfm option to be true.
225 * Enable GFM line breaks. This option requires the gfm option to be true.
230 * Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
235 * Sanitize the output. Ignore any HTML that has been input.
240 * Optionally sanitize found HTML with a sanitizer function.
242 sanitizer?(html: string): string;
245 * Mangle autolinks (<email@domain.com>).
250 * Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic.
252 smartLists?: boolean;
255 * Shows an HTML error message when rendering fails.
260 * A function to highlight code blocks. The function takes three arguments: code, lang, and callback.
262 highlight?(code: string, lang: string, callback?: (error: any | undefined, code: string) => void): string;
265 * Set the prefix for code block classes.
270 * Use "smart" typograhic punctuation for things like quotes and dashes.
272 smartypants?: boolean;
275 * Set the prefix for header tag ids.
277 headerPrefix?: string;
280 * Generate closing slash for self-closing tags (<br/> instead of <br>)