diff --git a/src/generators/legacy-html/utils/buildContent.mjs b/src/generators/legacy-html/utils/buildContent.mjs index 46c230b5..9b0e9a3b 100644 --- a/src/generators/legacy-html/utils/buildContent.mjs +++ b/src/generators/legacy-html/utils/buildContent.mjs @@ -76,13 +76,35 @@ const buildHtmlTypeLink = node => { ); }; +/** + * Creates a history table row. + * + * @param {ApiDocMetadataChange} change + * @param {import('unified').Processor} remark + */ +const createHistoryTableRow = ( + { version: changeVersions, description }, + remark +) => { + const descriptionNode = remark.parse(description); + + return createElement('tr', [ + createElement( + 'td', + Array.isArray(changeVersions) ? changeVersions.join(', ') : changeVersions + ), + createElement('td', descriptionNode), + ]); +}; + /** * Builds the Metadata Properties into content * - * @param {ApiDocMetadataEntry} node The node to build to build the properties from + * @param {ApiDocMetadataEntry} node The node to build the properties from + * @param {import('unified').Processor} remark The Remark instance to be used to process changes table * @returns {import('unist').Parent} The HTML AST tree of the properties content */ -const buildMetadataElement = node => { +const buildMetadataElement = (node, remark) => { const metadataElement = createElement('div.api_metadata'); // 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 => { if (typeof node.changes !== 'undefined' && node.changes.length) { // Maps the changes into a `tr` element with the version and the description // An array containing hast nodes for the history entries if any - const historyEntries = node.changes.map( - ({ version: changeVersions, description }) => - createElement('tr', [ - createElement( - 'td', - Array.isArray(changeVersions) - ? changeVersions.join(', ') - : changeVersions - ), - createElement('td', description), - ]) + const historyEntries = node.changes.map(change => + createHistoryTableRow(change, remark) ); const historyDetailsElement = createElement('details.changelog', [ @@ -227,7 +240,7 @@ export default (headNodes, metadataEntries, remark) => { // Concatenates all the strings and parses with remark into an AST tree return createElement('section', [ headingNode, - buildMetadataElement(entry), + buildMetadataElement(entry, remark), buildExtraContent(headNodes, entry), ...restNodes, ]);