fix: markdown table content in search results

This commit is contained in:
mrkaye97
2026-03-18 15:50:03 -04:00
parent 2b53c71a12
commit 8637cf4ed8
+11
View File
@@ -536,6 +536,16 @@ function convertFileTree(text: string): string {
);
}
function convertMarkdownTables(text: string): string {
// Remove separator rows (e.g. | --- | --- |)
text = text.replace(/^\|[-|\s:]+\|$/gm, "");
// Convert data/header rows: strip pipes and join cells with commas
text = text.replace(/^\|(.+)\|$/gm, (_match, inner: string) =>
inner.split("|").map((c: string) => c.trim()).filter(Boolean).join(", "),
);
return text;
}
function stripJsxComponents(text: string): string {
// Self-closing JSX tags
text = text.replace(/<[A-Z]\w*(?:\.\w+)*\s*[^>]*\/\s*>/g, "");
@@ -639,6 +649,7 @@ function convertMdxToMarkdown(
text = convertSteps(text);
text = convertCards(text);
text = convertFileTree(text);
text = convertMarkdownTables(text);
text = stripJsxComponents(text);
text = cleanBlankLines(text);