MCPcopy Index your code
hub / github.com/simstudioai/sim / extractHeadings

Method extractHeadings

apps/sim/lib/file-parsers/html-parser.ts:248–263  ·  view source on GitHub ↗

* Extract heading structure for metadata

($: cheerio.CheerioAPI)

Source from the content-addressed store, hash-verified

246 * Extract heading structure for metadata
247 */
248 private extractHeadings($: cheerio.CheerioAPI): Array<{ level: number; text: string }> {
249 const headings: Array<{ level: number; text: string }> = []
250
251 $('h1, h2, h3, h4, h5, h6').each((_, element) => {
252 const $element = $(element)
253 const tagName = element.tagName?.toLowerCase()
254 const level = Number.parseInt(tagName?.charAt(1) || '1', 10)
255 const text = $element.text().trim()
256
257 if (text) {
258 headings.push({ level, text })
259 }
260 })
261
262 return headings
263 }
264
265 /**
266 * Extract links from the document

Callers 1

parseBufferMethod · 0.95

Calls 3

textMethod · 0.80
$Function · 0.50
pushMethod · 0.45

Tested by

no test coverage detected