File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,12 @@ function processComments(dom: DocumentFragment) {
103103 for ( const { dt, dd} of generateDescriptionPairs ( element ) ) {
104104 elements . push ( ...importNestedList ( dd ) ) ;
105105 const comment = dd
106- . map ( desc => getCommentText ( innerText ( desc ) ) )
106+ . map ( desc => {
107+ desc . normalize ( ) ;
108+ convertChildPre ( desc ) ;
109+ return getCommentText ( innerText ( desc ) )
110+ } )
111+ . filter ( text => text )
107112 . join ( "\n\n" ) ;
108113 for ( const key of dt . map ( term => getKey ( term . innerHTML ) ) ) {
109114 if ( ! key ) {
@@ -123,6 +128,21 @@ function processComments(dom: DocumentFragment) {
123128 return JSON . stringify ( result , undefined , 4 ) ;
124129}
125130
131+ function convertChildPre ( e : Element ) {
132+ for ( const pre of e . querySelectorAll ( "pre" ) ) {
133+ const code = pre . querySelector ( ":scope > code" ) as HTMLElement ;
134+ if ( ! code ) {
135+ continue ;
136+ }
137+ const text = innerText ( code , {
138+ getComputedStyle ( _ : Element ) {
139+ return { whiteSpace : "pre" } as CSSStyleDeclaration ;
140+ }
141+ } ) ;
142+ pre . textContent = "```\n" + text + "\n```" ;
143+ }
144+ }
145+
126146function getKey ( s : string ) {
127147 const keyRegexp = / # d o m - ( [ a - z A - Z 0 - 9 - _ ] + ) / i;
128148 const match = s . match ( keyRegexp ) ;
You can’t perform that action at this time.
0 commit comments