diff --git a/docs-site/scripts/build-search-index.ts b/docs-site/scripts/build-search-index.ts index 7f7b5383e..028662dcf 100644 --- a/docs-site/scripts/build-search-index.ts +++ b/docs-site/scripts/build-search-index.ts @@ -33,8 +33,14 @@ function getAllDocSlugs(nav: any[]): string[] { } function stripMdx(content: string): string { - return content - .replace(/<[^>]+>/g, "") + // Iteratively strip HTML tags to handle nested/malformed tags + let stripped = content; + let prev = ""; + while (prev !== stripped) { + prev = stripped; + stripped = stripped.replace(/<[^>]+>/g, ""); + } + return stripped .replace(/```[\s\S]*?```/g, "") .replace(/`[^`]+`/g, "") .replace(/!\[.*?\]\(.*?\)/g, "")