Elffuss BraidHub

kikocis/continue public

9df0fa5d79c7 · 990 BRawPermalink
1/**
2 * Determines if a given header string represents Markdown content.
3 *
4 * The function checks various patterns to identify Markdown headers:
5 * - Exact match with common Markdown identifiers (md, markdown, gfm, github-markdown)
6 * - Contains these identifiers preceded by a space
7 * - First word has a file extension of md, markdown, or gfm
8 *
9 * @param header - The string to check for Markdown indicators
10 * @returns True if the header represents Markdown content, false otherwise
11 */
12export function headerIsMarkdown(header: string): boolean {
13 return (
14 header === "md" ||
15 header === "markdown" ||
16 header === "gfm" ||
17 header === "github-markdown" ||
18 header.includes(" md") ||
19 header.includes(" markdown") ||
20 header.includes(" gfm") ||
21 header.includes(" github-markdown") ||
22 header.split(" ")[0]?.split(".").pop() === "md" ||
23 header.split(" ")[0]?.split(".").pop() === "markdown" ||
24 header.split(" ")[0]?.split(".").pop() === "gfm"
25 );
26}