@@ -6,20 +6,20 @@ import {
66 GITHUB_BLOB_URL ,
77 populate ,
88} from '@doc-kit/core/utils/configuration/templates.mjs' ;
9+ import { parseInline } from '@doc-kit/core/utils/inline.mjs' ;
910import { omitKeys } from '@doc-kit/core/utils/misc.mjs' ;
1011import { UNIST } from '@doc-kit/core/utils/queries/index.mjs' ;
1112import { transformNodesToString } from '@doc-kit/core/utils/unist.mjs' ;
1213import { h as createElement } from 'hastscript' ;
1314import { slice } from 'mdast-util-slice-markdown' ;
14- import remarkParse from 'remark-parse' ;
15- import { unified } from 'unified' ;
1615import { u as createTree } from 'unist-builder' ;
1716import { SKIP , visit } from 'unist-util-visit' ;
1817
1918import { createJSXElement } from './ast.mjs' ;
2019import { extractHeadings , extractTextContent } from './buildBarProps.mjs' ;
2120import { annotateOverloads } from './overloads.mjs' ;
2221import { getRemarkRecma as remark } from './remark.mjs' ;
22+ import { renderAsJSX } from './render.mjs' ;
2323import { JSX_IMPORTS } from '../../html/constants.mjs' ;
2424import {
2525 STABILITY_LEVELS ,
@@ -37,18 +37,6 @@ import {
3737 getFullName ,
3838} from './signature.mjs' ;
3939
40- /**
41- * Converts a markdown string to plain text by parsing it and extracting
42- * text and inline code values.
43- *
44- * @param {string } markdown - The markdown string to convert.
45- * @returns {string } The plain text representation.
46- */
47- const toPlainText = markdown =>
48- transformNodesToString (
49- unified ( ) . use ( remarkParse ) . parse ( markdown ) . children
50- ) . trim ( ) ;
51-
5240/**
5341 *
5442 */
@@ -68,12 +56,21 @@ export const gatherChangeEntries = entry => {
6856 label : `${ label } : ${ enforceArray ( entry [ field ] ) . join ( ', ' ) } ` ,
6957 } ) ) ;
7058
71- // Explicit changes with plain-text labels extracted from markdown
72- const explicitChanges = ( entry . changes || [ ] ) . map ( change => ( {
73- versions : enforceArray ( change . version ) ,
74- label : toPlainText ( change . description ) ,
75- url : change [ 'pr-url' ] ,
76- } ) ) ;
59+ // Explicit changes, whose markdown descriptions are rendered as JSX
60+ const explicitChanges = ( entry . changes || [ ] ) . map ( change => {
61+ const url = change [ 'pr-url' ] ;
62+ const nodes = parseInline ( change . description , Boolean ( url ) ) ;
63+
64+ return {
65+ versions : enforceArray ( change . version ) ,
66+ // The plain text backs the change's `aria-label` and React key
67+ label : transformNodesToString ( nodes ) . trim ( ) ,
68+ // `content` takes a ReactNode, so inline code, emphasis and links are
69+ // displayed as markup instead of as their markdown source
70+ content : renderAsJSX ( nodes ) ,
71+ url,
72+ } ;
73+ } ) ;
7774
7875 return [ ...lifecycleChanges , ...explicitChanges ] ;
7976} ;
0 commit comments