MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / stripMd

Function stripMd

dashboard/lcm/src/helpers.ts:150–162  ·  view source on GitHub ↗
(s: any)

Source from the content-addressed store, hash-verified

148
149/** Flatten markdown to readable plain text (for compact list previews/titles). */
150export function stripMd(s: any): string {
151 return String(s == null ? "" : s)
152 .replace(/```[\s\S]*?```/g, " ")
153 .replace(/`([^`]+)`/g, "$1")
154 .replace(/\*\*([^*]+)\*\*/g, "$1")
155 .replace(/\*([^*]+)\*/g, "$1")
156 .replace(/^#{1,6}\s+/gm, "")
157 .replace(/^\s*>\s?/gm, "")
158 .replace(/^\s*[-*+]\s+/gm, "")
159 .replace(/\[([^\]]+)\]\([^)\s]+\)/g, "$1")
160 .replace(/\s+/g, " ")
161 .trim();
162}
163
164/** Derive a short title from a summary: first heading, else first bold run,
165 * else the first sentence/line of the flattened text. */

Callers 4

SearchResultCardFunction · 0.90
NodeRefFunction · 0.90
AppFunction · 0.90
summaryTitleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected