@@ -395,6 +395,43 @@ describe('marked unit', () => {
395395 + '\n<dt><strong>Topic 2 walked</strong> - unwalked</dt><dd><em>Description 2 walked</em></dd></p>\n' ) ;
396396 } ) ;
397397
398+ it ( 'should walk child token arrays' , ( ) => {
399+ const walkableDescription = {
400+ extensions : [ {
401+ name : 'walkableDescription' ,
402+ level : 'inline' ,
403+ start ( src ) { return src . indexOf ( ':' ) ; } ,
404+ tokenizer ( src , tokens ) {
405+ const rule = / ^ : ( [ ^ : \n ] + ) : ( [ ^ : \n ] * ) (?: \n | $ ) / ;
406+ const match = rule . exec ( src ) ;
407+ if ( match ) {
408+ const token = {
409+ type : 'walkableDescription' ,
410+ raw : match [ 0 ] ,
411+ dt : [ this . lexer . inline ( match [ 1 ] . trim ( ) ) ] ,
412+ dd : [ [ this . lexer . inline ( match [ 2 ] . trim ( ) ) ] ]
413+ } ;
414+ return token ;
415+ }
416+ } ,
417+ renderer ( token ) {
418+ return `\n<dt>${ this . parser . parseInline ( token . dt [ 0 ] ) } </dt><dd>${ this . parser . parseInline ( token . dd [ 0 ] [ 0 ] ) } </dd>` ;
419+ } ,
420+ childTokens : [ 'dd' , 'dt' ]
421+ } ] ,
422+ walkTokens ( token ) {
423+ if ( token . type === 'text' ) {
424+ token . text += ' walked' ;
425+ }
426+ }
427+ } ;
428+ marked . use ( walkableDescription ) ;
429+ const html = marked . parse ( ': Topic 1 : Description 1\n'
430+ + ': **Topic 2** : *Description 2*' ) ;
431+ assert . strictEqual ( html , '<p>\n<dt>Topic 1 walked</dt><dd>Description 1 walked</dd>'
432+ + '\n<dt><strong>Topic 2 walked</strong></dt><dd><em>Description 2 walked</em></dd></p>\n' ) ;
433+ } ) ;
434+
398435 describe ( 'multiple extensions' , ( ) => {
399436 function createExtension ( name ) {
400437 return {
0 commit comments