Skip to content

Commit 55780a6

Browse files
fix: escape <tags> in llms.txt titles (#1450)
fix: escape tags in `llms.txt` titles Co-authored-by: Tee Ming <chewteeming01@gmail.com>
1 parent c4be25b commit 55780a6

File tree

1 file changed

+6
-2
lines changed
  • apps/svelte.dev/src/lib/server

1 file changed

+6
-2
lines changed

apps/svelte.dev/src/lib/server/llms.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ export function generate_llm_content(options: GenerateLlmContentOptions): string
5151
? minimize_content(document.body, options.minimize)
5252
: document.body;
5353
if (doc_content.trim() === '') continue;
54-
55-
content += `\n# ${document.metadata.title}\n\n`;
54+
// replaces <tags> with `<tags>`
55+
const doc_title = document.metadata.title.replace(
56+
/(?!`)<[a-zA-Z0-9:]+>(?!`)/g,
57+
(m) => `\`${m}\``
58+
);
59+
content += `\n# ${doc_title}\n\n`;
5660
content += doc_content;
5761
content += '\n';
5862
}

0 commit comments

Comments
 (0)