@@ -3,26 +3,6 @@ const remarkStringify = require('remark-stringify');
33const { unified } = require ( 'unified' ) ;
44const { visitParents } = require ( 'unist-util-visit-parents' ) ;
55
6- /**
7- * Updates the markdown content for better UX and compatibility with Docusaurus v3.
8- * @param {string } changelog The markdown content.
9- * @returns {string } The updated markdown content.
10- */
11- function updateChangelog ( changelog ) {
12- const pipeline = unified ( )
13- . use ( remarkParse )
14- . use ( removeGitCliffMarkers )
15- . use ( incrementHeadingLevels )
16- . use ( prettifyPRLinks )
17- . use ( linkifyUserTags )
18- . use ( remarkStringify ) ;
19-
20- changelog = pipeline . processSync ( changelog ) . toString ( ) ;
21- changelog = addFrontmatter ( changelog ) ;
22- changelog = escapeMDXCharacters ( changelog ) ;
23- return changelog ;
24- }
25-
266/**
277 * Bumps the headings levels in the markdown content. This function increases the depth
288 * of all headings in the content by 1. This is useful when the content is included in
@@ -60,7 +40,7 @@ const linkifyUserTags = () => (tree) => {
6040
6141 const directParent = parents [ parents . length - 1 ] ;
6242
63- if ( ! match || directParent . type === 'link' ) return ;
43+ if ( ! match || directParent . type === 'link' ) return 0 ;
6444
6545 const nodeIndexInParent = directParent . children . findIndex ( ( x ) => x === node ) ;
6646
@@ -95,7 +75,7 @@ const prettifyPRLinks = () => (tree) => {
9575 const prLinkRegex = / h t t p s : \/ \/ g i t h u b .c o m \/ [ ^ \s ] + \/ p u l l \/ ( \d + ) / g;
9676 const match = prLinkRegex . exec ( node . value ) ;
9777
98- if ( ! match ) return ;
78+ if ( ! match ) return 0 ;
9979
10080 const directParent = parents [ parents . length - 1 ] ;
10181 const nodeIndexInParent = directParent . children . findIndex ( ( x ) => x === node ) ;
@@ -148,6 +128,26 @@ function escapeMDXCharacters(changelog) {
148128 } ) ;
149129}
150130
131+ /**
132+ * Updates the markdown content for better UX and compatibility with Docusaurus v3.
133+ * @param {string } changelog The markdown content.
134+ * @returns {string } The updated markdown content.
135+ */
136+ function updateChangelog ( changelog ) {
137+ const pipeline = unified ( )
138+ . use ( remarkParse )
139+ . use ( removeGitCliffMarkers )
140+ . use ( incrementHeadingLevels )
141+ . use ( prettifyPRLinks )
142+ . use ( linkifyUserTags )
143+ . use ( remarkStringify ) ;
144+
145+ changelog = pipeline . processSync ( changelog ) . toString ( ) ;
146+ changelog = addFrontmatter ( changelog ) ;
147+ changelog = escapeMDXCharacters ( changelog ) ;
148+ return changelog ;
149+ }
150+
151151module . exports = {
152152 updateChangelog,
153153} ;
0 commit comments