( content: string, defaultDescription: string = 'Custom item', )
| 93 | * Uses the first non-empty line as the description, or falls back to a default |
| 94 | */ |
| 95 | export function extractDescriptionFromMarkdown( |
| 96 | content: string, |
| 97 | defaultDescription: string = 'Custom item', |
| 98 | ): string { |
| 99 | const lines = content.split('\n') |
| 100 | for (const line of lines) { |
| 101 | const trimmed = line.trim() |
| 102 | if (trimmed) { |
| 103 | // If it's a header, strip the header prefix |
| 104 | const headerMatch = trimmed.match(/^#+\s+(.+)$/) |
| 105 | const text = headerMatch?.[1] ?? trimmed |
| 106 | |
| 107 | // Return the text, limited to reasonable length |
| 108 | return text.length > 100 ? text.substring(0, 97) + '...' : text |
| 109 | } |
| 110 | } |
| 111 | return defaultDescription |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Parses tools from frontmatter, supporting both string and array formats |
no outgoing calls
no test coverage detected