11const remarkParse = require ( 'remark-parse' ) ;
22const remarkStringify = require ( 'remark-stringify' ) ;
33const { unified } = require ( 'unified' ) ;
4- const { visitParents } = require ( 'unist-util-visit-parents' ) ;
4+ const { visitParents, CONTINUE } = require ( 'unist-util-visit-parents' ) ;
55
66/**
77 * Bumps the headings levels in the markdown content. This function increases the depth
@@ -40,7 +40,7 @@ const linkifyUserTags = () => (tree) => {
4040
4141 const directParent = parents [ parents . length - 1 ] ;
4242
43- if ( ! match || directParent . type === 'link' ) return 0 ;
43+ if ( ! match || directParent . type === 'link' ) return CONTINUE ;
4444
4545 const nodeIndexInParent = directParent . children . findIndex ( ( x ) => x === node ) ;
4646
@@ -57,10 +57,10 @@ const linkifyUserTags = () => (tree) => {
5757 node . value = before ;
5858 directParent . children . splice ( nodeIndexInParent + 1 , 0 , link ) ;
5959
60- if ( ! after ) return nodeIndexInParent + 2 ;
60+ if ( ! after ) return [ CONTINUE , nodeIndexInParent + 2 ] ;
6161
6262 directParent . children . splice ( nodeIndexInParent + 2 , 0 , { type : 'text' , value : `${ ending } ${ after } ` } ) ;
63- return nodeIndexInParent + 3 ;
63+ return [ CONTINUE , nodeIndexInParent + 3 ] ;
6464 } ) ;
6565} ;
6666
@@ -75,7 +75,7 @@ const prettifyPRLinks = () => (tree) => {
7575 const prLinkRegex = / h t t p s : \/ \/ g i t h u b .c o m \/ [ ^ \s ] + \/ p u l l \/ ( \d + ) / g;
7676 const match = prLinkRegex . exec ( node . value ) ;
7777
78- if ( ! match ) return 0 ;
78+ if ( ! match ) return CONTINUE ;
7979
8080 const directParent = parents [ parents . length - 1 ] ;
8181 const nodeIndexInParent = directParent . children . findIndex ( ( x ) => x === node ) ;
@@ -92,10 +92,10 @@ const prettifyPRLinks = () => (tree) => {
9292 node . value = before ;
9393
9494 directParent . children . splice ( nodeIndexInParent + 1 , 0 , link ) ;
95- if ( ! after ) return nodeIndexInParent + 1 ;
95+ if ( ! after ) return [ CONTINUE , nodeIndexInParent + 1 ] ;
9696
9797 directParent . children . splice ( nodeIndexInParent + 2 , 0 , { type : 'text' , value : after } ) ;
98- return nodeIndexInParent + 2 ;
98+ return [ CONTINUE , nodeIndexInParent + 2 ] ;
9999 } ) ;
100100} ;
101101
0 commit comments