MCPcopy Create free account
hub / github.com/R44VC0RP/opencode.cafe / parseMarkdownTable

Function parseMarkdownTable

scripts/import-awesome-list.ts:49–87  ·  view source on GitHub ↗
(section: string, category: string)

Source from the content-addressed store, hash-verified

47}
48
49function parseMarkdownTable(section: string, category: string): ParsedExtension[] {
50 const extensions: ParsedExtension[] = []
51
52 // Split into lines and process each table row
53 const lines = section.split("\n")
54
55 for (const line of lines) {
56 // Skip non-table lines
57 if (!line.startsWith("|")) continue
58 // Skip header and separator rows
59 if (line.includes("|---|") || line.match(/\|Name\|Stars\|Description\|/i)) continue
60
61 // Match: |[Name](url)|stars badge or -|Description|
62 const match = line.match(/^\|\[([^\]]+)\]\(([^)]+)\)\|[^|]*\|([^|]+)\|?$/)
63 if (!match) continue
64
65 const [, name, url, description] = match
66
67 // Skip if it's just a header row or empty
68 if (!name || !url || name === "Name") continue
69
70 const extension: ParsedExtension = {
71 name: name.trim(),
72 url: url.trim(),
73 description: description.trim(),
74 category,
75 }
76
77 const githubInfo = extractGitHubInfo(url)
78 if (githubInfo) {
79 extension.repoOwner = githubInfo.owner
80 extension.repoName = githubInfo.repo
81 }
82
83 extensions.push(extension)
84 }
85
86 return extensions
87}
88
89function parseReadme(content: string): ParsedExtension[] {
90 const allExtensions: ParsedExtension[] = []

Callers 1

parseReadmeFunction · 0.85

Calls 1

extractGitHubInfoFunction · 0.85

Tested by

no test coverage detected