MCPcopy Index your code
hub / github.com/codeaashu/claude-code / extractDescriptionFromMarkdown

Function extractDescriptionFromMarkdown

src/utils/markdownConfigLoader.ts:52–69  ·  view source on GitHub ↗
(
  content: string,
  defaultDescription: string = 'Custom item',
)

Source from the content-addressed store, hash-verified

50 * Uses the first non-empty line as the description, or falls back to a default
51 */
52export function extractDescriptionFromMarkdown(
53 content: string,
54 defaultDescription: string = 'Custom item',
55): string {
56 const lines = content.split('\n')
57 for (const line of lines) {
58 const trimmed = line.trim()
59 if (trimmed) {
60 // If it's a header, strip the header prefix
61 const headerMatch = trimmed.match(/^#+\s+(.+)$/)
62 const text = headerMatch?.[1] ?? trimmed
63
64 // Return the text, limited to reasonable length
65 return text.length > 100 ? text.substring(0, 97) + '...' : text
66 }
67 }
68 return defaultDescription
69}
70
71/**
72 * Parses tools from frontmatter, supporting both string and array formats

Callers 4

createPluginCommandFunction · 0.85
loadOutputStyleFromFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected