MCPcopy Create free account
hub / github.com/simstudioai/sim / extractHeaders

Method extractHeaders

apps/sim/lib/chunkers/docs-chunker.ts:133–152  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

131 }
132
133 private extractHeaders(content: string): HeaderInfo[] {
134 const headers: HeaderInfo[] = []
135 const headerRegex = /^(#{1,6})\s+(.+)$/gm
136 let match
137
138 while ((match = headerRegex.exec(content)) !== null) {
139 const level = match[1].length
140 const text = match[2].trim()
141 const anchor = this.generateAnchor(text)
142
143 headers.push({
144 text,
145 level,
146 anchor,
147 position: match.index,
148 })
149 }
150
151 return headers
152 }
153
154 private generateAnchor(headerText: string): string {
155 return headerText

Callers 1

chunkMdxFileMethod · 0.95

Calls 2

generateAnchorMethod · 0.95
pushMethod · 0.45

Tested by

no test coverage detected