@@ -3,26 +3,6 @@ const remarkStringify = require('remark-stringify');
3
3
const { unified } = require ( 'unified' ) ;
4
4
const { visitParents } = require ( 'unist-util-visit-parents' ) ;
5
5
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
-
26
6
/**
27
7
* Bumps the headings levels in the markdown content. This function increases the depth
28
8
* of all headings in the content by 1. This is useful when the content is included in
@@ -60,7 +40,7 @@ const linkifyUserTags = () => (tree) => {
60
40
61
41
const directParent = parents [ parents . length - 1 ] ;
62
42
63
- if ( ! match || directParent . type === 'link' ) return ;
43
+ if ( ! match || directParent . type === 'link' ) return 0 ;
64
44
65
45
const nodeIndexInParent = directParent . children . findIndex ( ( x ) => x === node ) ;
66
46
@@ -95,7 +75,7 @@ const prettifyPRLinks = () => (tree) => {
95
75
const prLinkRegex = / h t t p s : \/ \/ g i t h u b .c o m \/ [ ^ \s ] + \/ p u l l \/ ( \d + ) / g;
96
76
const match = prLinkRegex . exec ( node . value ) ;
97
77
98
- if ( ! match ) return ;
78
+ if ( ! match ) return 0 ;
99
79
100
80
const directParent = parents [ parents . length - 1 ] ;
101
81
const nodeIndexInParent = directParent . children . findIndex ( ( x ) => x === node ) ;
@@ -148,6 +128,26 @@ function escapeMDXCharacters(changelog) {
148
128
} ) ;
149
129
}
150
130
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
+
151
151
module . exports = {
152
152
updateChangelog,
153
153
} ;
0 commit comments