From b6a784eb63de0968e05becb05aa8495d191b12f8 Mon Sep 17 00:00:00 2001 From: mohamedh Date: Fri, 23 Oct 2026 16:21:01 +0100 Subject: [PATCH] chore(docs): upgrade to nimbus-docs 0.19.0 --- packages/cloudflare-api-site/nimbus.json | 2 +- packages/cloudflare-api-site/package.json | 2 +- .../src/description-markdown.test.ts | 16 ++-- .../src/description-markdown.ts | 17 ++-- .../src/pages/[...slug].astro | 6 -- .../src/pages/[...slug]/index.md.ts | 3 +- .../src/pages/[...slug]/index.mdx.ts | 3 +- .../src/pages/llms-full.txt.ts | 1 - pnpm-lock.yaml | 85 +++++++------------ pnpm-workspace.yaml | 1 + 10 files changed, 52 insertions(+), 84 deletions(-) diff --git a/packages/cloudflare-api-site/nimbus.json b/packages/cloudflare-api-site/nimbus.json index cf64c5455..6bc49ab79 100644 --- a/packages/cloudflare-api-site/nimbus.json +++ b/packages/cloudflare-api-site/nimbus.json @@ -1,7 +1,7 @@ { "$schema": "https://nimbus-docs.com/schema/nimbus.json", "version": "0.7.12", - "lastReviewedNimbusVersion": "0.18.0", + "lastReviewedNimbusVersion": "0.19.0", "templatesTag": "templates-v0.7.12", "variant": "empty", "registry": "https://nimbus-docs.com/registry", diff --git a/packages/cloudflare-api-site/package.json b/packages/cloudflare-api-site/package.json index 6fa706588..8338cbf38 100644 --- a/packages/cloudflare-api-site/package.json +++ b/packages/cloudflare-api-site/package.json @@ -16,7 +16,7 @@ "dependencies": { "@astrojs/cloudflare": "^15.0.0-beta.2", "@astrojs/prism": "^4.0.2", - "@cloudflare/nimbus-docs": "^0.18.0", + "@cloudflare/nimbus-docs": "^0.19.0", "@fontsource-variable/inter": "5.3.0", "@fontsource-variable/jetbrains-mono": "5.3.0", "@iconify-json/ph": "^1.2.2", diff --git a/packages/cloudflare-api-site/src/description-markdown.test.ts b/packages/cloudflare-api-site/src/description-markdown.test.ts index c51478b11..420bff6cb 100644 --- a/packages/cloudflare-api-site/src/description-markdown.test.ts +++ b/packages/cloudflare-api-site/src/description-markdown.test.ts @@ -1,6 +1,6 @@ import assert from 'node:assert/strict'; import { test } from 'node:test'; -import { keepPlaceholders, renderDescription } from './description-markdown.ts'; +import { keepDroppedHtml, renderDescription } from './description-markdown.ts'; const ASTRO_FERN_PROBE = ' [probe](javascript:probe)'; @@ -19,13 +19,13 @@ test('placeholders inside code are left alone', () => { '~~~\nmetadata.\n~~~', 'Para\n\n metadata.\n\nafter', ]) { - assert.equal(keepPlaceholders(markdown), markdown); + assert.equal(keepDroppedHtml(markdown), markdown); } }); -test('a leading indent or blank lines are trimmed, as Nimbus does, so the placeholder is escaped', () => { - assert.equal(keepPlaceholders(' metadata. leading indent'), 'metadata.<key> leading indent'); - assert.equal(keepPlaceholders('\n\nmetadata. after blank lines'), 'metadata.<key> after blank lines'); +test('a leading indent or blank lines are trimmed, as Nimbus does, so the comment is escaped', () => { + assert.equal(keepDroppedHtml(' leading indent'), '<!--sse--> leading indent'); + assert.equal(keepDroppedHtml('\n\n after blank lines'), '<!--sse--> after blank lines'); }); test('escaped backticks around a placeholder still escape it', () => { @@ -38,7 +38,7 @@ test('already-escaped placeholders, autolinks and angle-bracket links are unchan 'Autolink ok', 'Link [a]() ok', ]) { - assert.equal(keepPlaceholders(markdown), markdown); + assert.equal(keepDroppedHtml(markdown), markdown); } assert.match( renderDescription(''), @@ -62,8 +62,8 @@ test('allowed tags still render, including a placeholder named like one', () => assert.equal(renderDescription('metadata.bold'), '

metadata.bold

\n'); }); -test('offsets count string characters, so text before a placeholder can be non-ASCII', () => { - assert.equal(keepPlaceholders('Ünïcödé — “quotes” then metadata.'), 'Ünïcödé — “quotes” then metadata.<key>'); +test('offsets count string characters, so text before a comment can be non-ASCII', () => { + assert.equal(keepDroppedHtml('Ünïcödé — “quotes” then '), 'Ünïcödé — “quotes” then <!--sse-->'); }); test('unsafe HTML and links stay inert', () => { diff --git a/packages/cloudflare-api-site/src/description-markdown.ts b/packages/cloudflare-api-site/src/description-markdown.ts index 35cf444fd..173b6630a 100644 --- a/packages/cloudflare-api-site/src/description-markdown.ts +++ b/packages/cloudflare-api-site/src/description-markdown.ts @@ -8,7 +8,7 @@ interface MdastNode { children?: MdastNode[]; } -const ALLOWED_TAGS = new Set((defaultSchema.tagNames ?? []).map((name) => name.toLowerCase())); +const DROPPED_TAGS = new Set((defaultSchema.strip ?? []).map((name) => name.toLowerCase())); const TAG_NAME = /^<\/?([A-Za-z][A-Za-z0-9-]*)/; function htmlRanges(node: MdastNode, ranges: [number, number][]): [number, number][] { @@ -19,18 +19,15 @@ function htmlRanges(node: MdastNode, ranges: [number, number][]): [number, numbe return ranges; } -function escapeUnknownTags(html: string): string { +function escapeDroppedTags(html: string): string { return html.replace(/ { const name = TAG_NAME.exec(html.slice(offset))?.[1]?.toLowerCase(); - return name !== undefined && ALLOWED_TAGS.has(name) ? lt : '<'; + return name === undefined || DROPPED_TAGS.has(name) ? '<' : lt; }); } -/** - * Escapes raw HTML the sanitizer would drop, such as `metadata.` placeholders and comments, so - * it shows as text. Trims like Nimbus's renderer, so both parse the same block structure. - */ -export function keepPlaceholders(markdown: string): string { +// Nimbus keeps unknown tags such as `metadata.` as text but drops comments and `