From c834e5c75e77395723c52e17f495bd4bf7701045 Mon Sep 17 00:00:00 2001 From: ComputerGuy <63362464+Ocean-OS@users.noreply.github.com> Date: Sun, 3 Aug 2025 20:24:13 -0700 Subject: [PATCH] fix: escape tags in `llms.txt` titles --- apps/svelte.dev/src/lib/server/llms.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/svelte.dev/src/lib/server/llms.ts b/apps/svelte.dev/src/lib/server/llms.ts index 4892c2728..69ae4fe76 100644 --- a/apps/svelte.dev/src/lib/server/llms.ts +++ b/apps/svelte.dev/src/lib/server/llms.ts @@ -51,8 +51,12 @@ export function generate_llm_content(options: GenerateLlmContentOptions): string ? minimize_content(document.body, options.minimize) : document.body; if (doc_content.trim() === '') continue; - - content += `\n# ${document.metadata.title}\n\n`; + // replaces with `` + const doc_title = document.metadata.title.replace( + /(?!`)<[a-zA-Z0-9:]+>(?!`)/g, + (m) => `\`${m}\`` + ); + content += `\n# ${doc_title}\n\n`; content += doc_content; content += '\n'; }