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 | 88x 7x 7x | /**
* Captures the opening fence, body and closing fence of a triplate frontmatter block.
*/
const FRONTMATTER_RE = /^(---[ \t]*\r?\n)([\s\S]*?)\r?\n---[ \t]*(\r?\n|$)/;
/**
* Returns the offset at which the document body begins, i.e. the character after the
* closing `---` line of a triplate frontmatter block, or `0` when there is no frontmatter.
* Used to anchor edits (e.g. inserting a prefix declaration) below a triplate header.
*/
export function getContentStartOffset(text: string): number {
const m = text.match(FRONTMATTER_RE);
return m ? m[0].length : 0;
}
|