forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
marked.d.ts
164 lines (140 loc) · 4.54 KB
/
marked.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// Type definitions for Marked
// Project: https://github.com/chjj/marked
// Definitions by: William Orr <https://github.com/worr>
// Definitions: https://github.com/DefinitelyTyped/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): MarkedStatic;
Renderer: {
new(): MarkedRenderer;
}
Parser: {
new(options: MarkedOptions): MarkedParser;
}
}
interface MarkedRenderer {
code(code: string, language: string): string;
blockquote(quote: string): string;
html(html: string): string;
heading(text: string, level: number, raw: string): string;
hr(): string;
list(body: string, ordered: boolean): string;
listitem(text: string): string;
paragraph(text: string): string;
table(header: string, body: string): string;
tablerow(content: string): string;
tablecell(content: string, flags: {
header: boolean,
align: string
}): string;
strong(text: string): string;
em(text: string): string;
codespan(code: string): string;
br(): string;
del(text: string): string;
link(href: string, title: string, text: string): string;
image(href: string, title: string, text: string): string;
text(text: string): string;
}
interface MarkedParser {
parse(source: any[]): string
}
interface MarkedOptions {
/**
* Type: object Default: new Renderer()
*
* An object containing functions to render tokens to HTML.
*/
renderer?: MarkedRenderer;
/**
* 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" {
export = marked;
}
declare var marked: MarkedStatic;