74a11ae8fc40e63447d779629e9eec957f603731
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / ux / help / help-module / src / main / resources / help / lib / marked.d.ts
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
6
7 declare var marked : marked.markedStatic;
8
9 export as namespace marked;
10
11 export = marked;
12
13 declare namespace marked {
14     /**
15      * Compiles markdown to HTML.
16      *
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
20      */
21     function markedStatic(src: string, callback: (error: any | undefined, parseResult: string) => void): string;
22
23     /**
24      * Compiles markdown to HTML.
25      *
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
30      */
31     function markedStatic(src: string, options?: marked.MarkedOptions, callback?: (error: any | undefined, parseResult: string) => void): string;
32
33     /**
34      * @param src String of markdown source to be compiled
35      * @param options Hash of options
36      */
37     function lexer(src: string, options?: MarkedOptions): TokensList;
38
39     /**
40      * Compiles markdown to HTML.
41      *
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
45      */
46     function parse(src: string, callback: (error: any | undefined, parseResult: string) => void): string;
47
48     /**
49      * Compiles markdown to HTML.
50      *
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
55      */
56     function parse(src: string, options?: MarkedOptions, callback?: (error: any | undefined, parseResult: string) => void): string;
57
58     /**
59      * @param src Tokenized source as array of tokens
60      * @param options Hash of options
61      */
62     function parser(src: TokensList, options?: MarkedOptions): string;
63
64     /**
65      * Sets the default options.
66      *
67      * @param options Hash of options
68      */
69     function setOptions(options: MarkedOptions): typeof marked;
70
71     class Renderer {
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;
77         hr(): 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: {
84             header: boolean;
85             align: 'center' | 'left' | 'right' | null;
86         }): string;
87         strong(text: string): string;
88         em(text: string): string;
89         codespan(code: string): string;
90         br(): 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;
95     }
96
97     class Lexer {
98         rules: Rules;
99         tokens: TokensList;
100         constructor(options?: MarkedOptions);
101         lex(src: string): TokensList;
102     }
103
104     interface Rules {
105         [ruleName: string]: RegExp | Rules;
106     }
107
108     type TokensList = Token[] & {
109         links: {
110             [key: string]: { href: string; title: string; }
111         }
112     };
113
114     type Token =
115         Tokens.Space
116         | Tokens.Code
117         | Tokens.Heading
118         | Tokens.Table
119         | Tokens.Hr
120         | Tokens.BlockquoteStart
121         | Tokens.BlockquoteEnd
122         | Tokens.ListStart
123         | Tokens.LooseItemStart
124         | Tokens.ListItemStart
125         | Tokens.ListItemEnd
126         | Tokens.ListEnd
127         | Tokens.Paragraph
128         | Tokens.HTML
129         | Tokens.Text;
130
131     namespace Tokens {
132         interface Space {
133             type: 'space';
134         }
135
136         interface Code {
137             type: 'code';
138             lang?: string;
139             text: string;
140         }
141
142         interface Heading {
143             type: 'heading';
144             depth: number;
145             text: string;
146         }
147
148         interface Table {
149             type: 'table';
150             header: string[];
151             align: Array<'center' | 'left' | 'right' | null>;
152             cells: string[][];
153         }
154
155         interface Hr {
156             type: 'hr';
157         }
158
159         interface BlockquoteStart {
160             type: 'blockquote_start';
161         }
162
163         interface BlockquoteEnd {
164             type: 'blockquote_end';
165         }
166
167         interface ListStart {
168             type: 'list_start';
169             ordered: boolean;
170         }
171
172         interface LooseItemStart {
173             type: 'loose_item_start';
174         }
175
176         interface ListItemStart {
177             type: 'list_item_start';
178         }
179
180         interface ListItemEnd {
181             type: 'list_item_end';
182         }
183
184         interface ListEnd {
185             type: 'list_end';
186         }
187
188         interface Paragraph {
189             type: 'paragraph';
190             pre?: boolean;
191             text: string;
192         }
193
194         interface HTML {
195             type: 'html';
196             pre: boolean;
197             text: string;
198         }
199
200         interface Text {
201             type: 'text';
202             text: string;
203         }
204     }
205
206     interface MarkedOptions {
207         /**
208          * Type: object Default: new Renderer()
209          *
210          * An object containing functions to render tokens to HTML.
211          */
212         renderer?: Renderer;
213
214         /**
215          * Enable GitHub flavored markdown.
216          */
217         gfm?: boolean;
218
219         /**
220          * Enable GFM tables. This option requires the gfm option to be true.
221          */
222         tables?: boolean;
223
224         /**
225          * Enable GFM line breaks. This option requires the gfm option to be true.
226          */
227         breaks?: boolean;
228
229         /**
230          * Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
231          */
232         pedantic?: boolean;
233
234         /**
235          * Sanitize the output. Ignore any HTML that has been input.
236          */
237         sanitize?: boolean;
238
239         /**
240          * Optionally sanitize found HTML with a sanitizer function.
241          */
242         sanitizer?(html: string): string;
243
244         /**
245          * Mangle autolinks (<email@domain.com>).
246          */
247         mangle?: boolean;
248
249         /**
250          * Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic.
251          */
252         smartLists?: boolean;
253
254         /**
255          * Shows an HTML error message when rendering fails.
256          */
257         silent?: boolean;
258
259         /**
260          * A function to highlight code blocks. The function takes three arguments: code, lang, and callback.
261          */
262         highlight?(code: string, lang: string, callback?: (error: any | undefined, code: string) => void): string;
263
264         /**
265          * Set the prefix for code block classes.
266          */
267         langPrefix?: string;
268
269         /**
270          * Use "smart" typograhic punctuation for things like quotes and dashes.
271          */
272         smartypants?: boolean;
273
274         /**
275          * Set the prefix for header tag ids.
276          */
277         headerPrefix?: string;
278
279         /**
280          * Generate closing slash for self-closing tags (<br/> instead of <br>)
281          */
282         xhtml?: boolean;
283     }
284 }