Skip to content

Commit 44e1cd4

Browse files
committed
Render <note>, <internal> better
1 parent a5e2c8a commit 44e1cd4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/scrapers/wiki-page-markup-scraper.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export function isClass(page: WikiPage): page is TypePage {
141141
}
142142

143143
// Handle things like <page> tags, <warning>, etc.
144+
const classBlocks = ["internal", "note", "warning"];
144145
function markdownifyDescription($: CheerioAPI, e: Cheerio<AnyNode>): string {
145146
// <page> => markdown []()
146147
for (const page of $(e).find('page')) {
@@ -150,6 +151,15 @@ function markdownifyDescription($: CheerioAPI, e: Cheerio<AnyNode>): string {
150151
$p.replaceWith( `[${text}](${url})` );
151152
}
152153

154+
for (const className of classBlocks) {
155+
for (const block of $(e).find(className)) {
156+
const $b = $(block);
157+
let text = markdownifyDescription($, $b).trim();
158+
if (className === 'internal' && text === '') text = `This is used internally - although you're able to use it you probably shouldn't.`;
159+
$b.replaceWith( `**${className.toUpperCase()}**: ${text}\n` );
160+
}
161+
}
162+
153163
let description = $(e).text();
154164

155165
// Fixup []() that use local URLs. This is not exclusive to the result of <page> conversions

0 commit comments

Comments
 (0)