INNER CODE UNIT · TypeScript
parseFrontmatter
cyanheads/pubmed-mcp-server · scripts/build-changelog.ts:85
function parseFrontmatter(content: string, fileLabel: string): Frontmatter {
const match = content.match(/^---\n([\s\S]*?)\n---\n?/);
if (!match) return { summary: null, breaking: false, security: false };
const block = match[1] as string;
// summary: quoted or bare, single line
let summary: string | null = null;
const summaryMatch = block.match(/^summary:\s*(.*)$/m);
if (summaryMatch) {
let raw = (summaryMatch[1] ?? '').trim();
if ((raw.startsWith('"') && raw.endsWith('"')) || (raw.startsWith("'") && raw.endsWith("'"))) {
raw = raw.slice(1, -1);
}
summary = raw.length > 0 ? raw : null;
}
if (summary !== null && summary.length > SUMMARY_MAX_LENGTH) {
throw new Error(