MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / findHeading

Function findHeading

lib/embed-docs/utils.ts:262–274  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

260}
261
262export function findHeading(text: string): { text: string; heading: string } {
263 const lines = text.split("\n");
264 const firstLineIdx = lines.findIndex(Boolean);
265 if (firstLineIdx === -1) return { text: "", heading: "" };
266 const firstLineClean = RemoveMarkdown(lines[firstLineIdx]);
267 const isHeading = firstLineClean.length < 100;
268
269 return {
270 // The <100 is to remove paragraphs after genuine empty headings
271 text: (isHeading ? lines.slice(firstLineIdx + 1) : lines).join("\n"),
272 heading: isHeading ? firstLineClean : "",
273 };
274}
275
276export function removeMDLinksImgs(text: string): string {
277 /** Remove Markdown doesn't remove links which are spread over multiple lines **/

Callers 1

splitTextByHeadersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected