@@ -91,126 +91,6 @@ export function smart_quotes(str: string) {
91
91
} ) ;
92
92
}
93
93
94
- const default_renderer : Partial < Renderer > = {
95
- code ( code , infostring , escaped ) {
96
- const lang = infostring ?. match ( / \S * / ) ?. [ 0 ] ;
97
-
98
- code = code . replace ( / \n $ / , '' ) + '\n' ;
99
-
100
- if ( ! lang ) {
101
- return '<pre><code>' + ( escaped ? code : escape ( code , true ) ) + '</code></pre>\n' ;
102
- }
103
-
104
- return (
105
- '<pre><code class="language-' +
106
- escape ( lang , true ) +
107
- '">' +
108
- ( escaped ? code : escape ( code , true ) ) +
109
- '</code></pre>\n'
110
- ) ;
111
- } ,
112
-
113
- blockquote ( quote ) {
114
- return '<blockquote>\n' + quote + '</blockquote>\n' ;
115
- } ,
116
-
117
- html ( html ) {
118
- return html ;
119
- } ,
120
-
121
- heading ( text , level ) {
122
- return '<h' + level + '>' + text + '</h' + level + '>\n' ;
123
- } ,
124
-
125
- hr ( ) {
126
- return '<hr>\n' ;
127
- } ,
128
-
129
- list ( body , ordered , start ) {
130
- const type = ordered ? 'ol' : 'ul' ,
131
- startatt = ordered && start !== 1 ? ' start="' + start + '"' : '' ;
132
- return '<' + type + startatt + '>\n' + body + '</' + type + '>\n' ;
133
- } ,
134
-
135
- listitem ( text ) {
136
- return '<li>' + text + '</li>\n' ;
137
- } ,
138
-
139
- checkbox ( checked ) {
140
- return '<input ' + ( checked ? 'checked="" ' : '' ) + 'disabled="" type="checkbox"' + '' + '> ' ;
141
- } ,
142
-
143
- paragraph ( text ) {
144
- return '<p>' + text + '</p>\n' ;
145
- } ,
146
-
147
- table ( header , body ) {
148
- if ( body ) body = '<tbody>' + body + '</tbody>' ;
149
-
150
- return '<table>\n' + '<thead>\n' + header + '</thead>\n' + body + '</table>\n' ;
151
- } ,
152
-
153
- tablerow ( content ) {
154
- return '<tr>\n' + content + '</tr>\n' ;
155
- } ,
156
-
157
- tablecell ( content , flags ) {
158
- const type = flags . header ? 'th' : 'td' ;
159
- const tag = flags . align ? '<' + type + ' align="' + flags . align + '">' : '<' + type + '>' ;
160
- return tag + content + '</' + type + '>\n' ;
161
- } ,
162
-
163
- // span level renderer
164
- strong ( text ) {
165
- return '<strong>' + text + '</strong>' ;
166
- } ,
167
-
168
- em ( text ) {
169
- return '<em>' + text + '</em>' ;
170
- } ,
171
-
172
- codespan ( text ) {
173
- return '<code>' + text + '</code>' ;
174
- } ,
175
-
176
- br ( ) {
177
- return '<br>' ;
178
- } ,
179
-
180
- del ( text ) {
181
- return '<del>' + text + '</del>' ;
182
- } ,
183
-
184
- link ( href , title , text ) {
185
- if ( href === null ) {
186
- return text ;
187
- }
188
- let out = '<a href="' + escape ( href ) + '"' ;
189
- if ( title ) {
190
- out += ' title="' + title + '"' ;
191
- }
192
- out += '>' + text + '</a>' ;
193
- return out ;
194
- } ,
195
-
196
- image ( href , title , text ) {
197
- if ( href === null ) {
198
- return text ;
199
- }
200
-
201
- let out = '<img src="' + href + '" alt="' + text + '"' ;
202
- if ( title ) {
203
- out += ' title="' + title + '"' ;
204
- }
205
- out += '>' ;
206
- return out ;
207
- } ,
208
-
209
- text ( text ) {
210
- return text ;
211
- }
212
- } ;
213
-
214
94
const tokenizer : TokenizerObject = {
215
95
url ( src ) {
216
96
// if `src` is a package version string, eg: [email protected]
@@ -225,10 +105,7 @@ const tokenizer: TokenizerObject = {
225
105
226
106
export async function transform ( markdown : string , renderer : Partial < Renderer > = { } ) {
227
107
const marked = new Marked ( {
228
- renderer : {
229
- ...default_renderer ,
230
- ...renderer
231
- } ,
108
+ renderer,
232
109
tokenizer
233
110
} ) ;
234
111
0 commit comments