INNER CODE UNIT · TypeScript
parseReadme
ahmet/awesome-web3 · lib/catalog.ts:147
export function parseReadme(markdown: string): Catalog {
const tree = unified().use(remarkParse).parse(markdown) as MdNode
const resources: Resource[] = []
const categoryMap = new Map<string, Category>()
let title = 'Awesome Web3'
let description = ''
let category: string | null = null
let subcategory: string | null = null
let started = false
for (const node of tree.children ?? []) {
if (node.type === 'heading' && node.depth === 1) {
title = textOf(node).trim() || title
continue
}
if (!started && (node.type === 'html' || node.type === 'paragraph')) {