@@ -259,42 +259,40 @@ async function parse({
259
259
// from linking to themselves
260
260
let current = '' ;
261
261
262
- /** @type {string } */
263
- const content = await transform ( body , {
264
- text : smart_quotes ,
265
- heading ( html , level , raw ) {
266
- const title = html
262
+ return await transform ( body , {
263
+ text ( { text } ) {
264
+ return smart_quotes ( text ) ;
265
+ } ,
266
+ heading ( { text, depth, raw } ) {
267
+ const title = text
267
268
. replace ( / < \/ ? c o d e > / g, '' )
268
269
. replace ( / & q u o t ; / g, '"' )
269
270
. replace ( / & l t ; / g, '<' )
270
271
. replace ( / & g t ; / g, '>' ) ;
271
-
272
272
current = title ;
273
-
274
273
const normalized = normalizeSlugify ( raw ) ;
275
-
276
- headings [ level - 1 ] = normalized ;
277
- headings . length = level ;
278
-
274
+ headings [ depth - 1 ] = normalized ;
275
+ headings . length = depth ;
279
276
const slug = headings . filter ( Boolean ) . join ( '-' ) ;
280
-
281
- return `<h${ level } id="${ slug } ">${ html . replace (
277
+ return `<h${ depth } id="${ slug } ">${ text . replace (
282
278
/ < \/ ? c o d e > / g,
283
279
''
284
- ) } <a href="#${ slug } " class="permalink"><span class="visually-hidden">permalink</span></a></h${ level } >`;
280
+ ) } <a href="#${ slug } " class="permalink"><span class="visually-hidden">permalink</span></a></h${ depth } >`;
285
281
} ,
286
- code : ( source , language ) => code ( source , language ?? 'js' , current ) ,
287
- codespan,
288
- blockquote : ( content ) => {
282
+ code ( { text, lang } ) {
283
+ return code ( text , lang ?? 'js' , current ) ;
284
+ } ,
285
+ codespan ( { text } ) {
286
+ return codespan ( text ) ;
287
+ } ,
288
+ blockquote ( token ) {
289
+ let content = this . parser ?. parse ( token . tokens ) ?? '' ;
289
290
if ( content . includes ( '[!LEGACY]' ) ) {
290
291
content = `<details class="legacy"><summary>Legacy mode</summary>${ content . replace ( '[!LEGACY]' , '' ) } </details>` ;
291
292
}
292
-
293
293
return `<blockquote>${ content } </blockquote>` ;
294
294
}
295
295
} ) ;
296
-
297
- return content ;
298
296
}
299
297
300
298
/**
0 commit comments