@@ -19,7 +19,7 @@ function getBreadcrumbs(article) {
19
19
*/
20
20
function dropIrrelevantSections ( article ) {
21
21
article . find ( [
22
- '.chapter:has(#what-s-next)' , '.chapter:has(#next-step)' ,
22
+ '.chapter:has(#what-s-next)' , '.chapter:has(#next-step)' , '.chapter:has(#next-steps)' ,
23
23
'.chapter:has(#learn-more)' , '.chapter:has(#leave-feedback)'
24
24
] . join ( ', ' ) ) . remove ( ) ;
25
25
}
@@ -39,6 +39,41 @@ function replaceMedia(article, pageUrl) {
39
39
}
40
40
}
41
41
42
+ /**
43
+ * @param {import('cheerio').Element } node
44
+ */
45
+ function cloneAttrsString ( node ) {
46
+ return Object . entries ( ( node . attribs || { } ) ) . map ( ( [ key , value ] ) => {
47
+ const val = typeof value === 'string' ? `="${ value } "` : '' ;
48
+ return `${ key } ${ val } ` ;
49
+ } ) . join ( ' ' ) ;
50
+ }
51
+
52
+ /**
53
+ * @param {import('cheerio').Cheerio } article
54
+ * @returns {void }
55
+ */
56
+ function replaceWRSSemantic ( article ) {
57
+ const listStrong = article . find ( 'span.control' ) ;
58
+
59
+ for ( let i = 0 , length = listStrong . length ; i < length ; i ++ ) {
60
+ const strong = listStrong . eq ( i ) ;
61
+ const node = listStrong [ i ] ;
62
+ const newNode = `<b ${ cloneAttrsString ( node ) } >${ strong . html ( ) } </b>` ;
63
+ strong . replaceWith ( newNode ) ;
64
+ }
65
+
66
+
67
+ const listCode = article . find ( 'div.code-block' ) ;
68
+
69
+ for ( let i = 0 , length = listCode . length ; i < length ; i ++ ) {
70
+ const code = listCode . eq ( i ) ;
71
+ const node = listStrong [ i ] ;
72
+ const newNode = `<code ${ cloneAttrsString ( node ) } >${ code . html ( ) } </code>` ;
73
+ code . replaceWith ( newNode ) . addClass ( 'code' ) ;
74
+ }
75
+ }
76
+
42
77
/**
43
78
* @param {import('cheerio').Cheerio } article
44
79
* @returns {void }
@@ -162,6 +197,7 @@ async function docs($, url, data) {
162
197
163
198
dropUiElements ( $article ) ;
164
199
dropIrrelevantSections ( $article ) ;
200
+ replaceWRSSemantic ( $article ) ;
165
201
replaceMedia ( $article , pageUrl . toString ( ) ) ;
166
202
167
203
const breadcrumbs = getBreadcrumbs ( $body ) ;
0 commit comments