Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 255x 144x 144x | // SPDX-FileCopyrightText: 2024-2026 Hack23 AB
// SPDX-License-Identifier: Apache-2.0
/**
* @module Aggregator/Clean/StripFrontmatter
* @description Remove YAML front-matter from the head of an artifact.
*/
/**
* Strip YAML front-matter from the head of a Markdown document. Matches
* `---\n...\n---\n` *only* at position 0 — quoted `---` dividers deeper in
* the document are left alone.
*
* @param md - Raw Markdown source
* @returns Markdown with the leading front-matter block removed
*/
export function stripFrontMatter(md: string): string {
if (!md.startsWith('---')) return md;
const match = /^---\r?\n[\s\S]*?\r?\n---\r?\n?/.exec(md);
return match ? md.slice(match[0].length) : md;
}
|