@@ -76,13 +76,35 @@ const buildHtmlTypeLink = node => {
76
76
) ;
77
77
} ;
78
78
79
+ /**
80
+ * Creates a history table row.
81
+ *
82
+ * @param {ApiDocMetadataChange } change
83
+ * @param {import('unified').Processor } remark
84
+ */
85
+ const createHistoryTableRow = (
86
+ { version : changeVersions , description } ,
87
+ remark
88
+ ) => {
89
+ const descriptionNode = remark . parse ( description ) ;
90
+
91
+ return createElement ( 'tr' , [
92
+ createElement (
93
+ 'td' ,
94
+ Array . isArray ( changeVersions ) ? changeVersions . join ( ', ' ) : changeVersions
95
+ ) ,
96
+ createElement ( 'td' , descriptionNode ) ,
97
+ ] ) ;
98
+ } ;
99
+
79
100
/**
80
101
* Builds the Metadata Properties into content
81
102
*
82
- * @param {ApiDocMetadataEntry } node The node to build to build the properties from
103
+ * @param {ApiDocMetadataEntry } node The node to build the properties from
104
+ * @param {import('unified').Processor } remark The Remark instance to be used to process changes table
83
105
* @returns {import('unist').Parent } The HTML AST tree of the properties content
84
106
*/
85
- const buildMetadataElement = node => {
107
+ const buildMetadataElement = ( node , remark ) => {
86
108
const metadataElement = createElement ( 'div.api_metadata' ) ;
87
109
88
110
// We use a `span` element to display the source link as a clickable link to the source within Node.js
@@ -159,17 +181,8 @@ const buildMetadataElement = node => {
159
181
if ( typeof node . changes !== 'undefined' && node . changes . length ) {
160
182
// Maps the changes into a `tr` element with the version and the description
161
183
// An array containing hast nodes for the history entries if any
162
- const historyEntries = node . changes . map (
163
- ( { version : changeVersions , description } ) =>
164
- createElement ( 'tr' , [
165
- createElement (
166
- 'td' ,
167
- Array . isArray ( changeVersions )
168
- ? changeVersions . join ( ', ' )
169
- : changeVersions
170
- ) ,
171
- createElement ( 'td' , description ) ,
172
- ] )
184
+ const historyEntries = node . changes . map ( change =>
185
+ createHistoryTableRow ( change , remark )
173
186
) ;
174
187
175
188
const historyDetailsElement = createElement ( 'details.changelog' , [
@@ -227,7 +240,7 @@ export default (headNodes, metadataEntries, remark) => {
227
240
// Concatenates all the strings and parses with remark into an AST tree
228
241
return createElement ( 'section' , [
229
242
headingNode ,
230
- buildMetadataElement ( entry ) ,
243
+ buildMetadataElement ( entry , remark ) ,
231
244
buildExtraContent ( headNodes , entry ) ,
232
245
...restNodes ,
233
246
] ) ;
0 commit comments