obsidian/functions/getFrontMatterInfo
Mock of Obsidian’s getFrontMatterInfo.
A port of Obsidian’s own implementation (1.14.x app.js, hg), not an approximation of it. Two of its habits are easy to get wrong:
frontmatterINCLUDES the newline that ends the last property line, andtois the index of the closing---itself. So[from, to)is exactly the region a caller replaces, and splicing in text that ends in a newline - whichstringifyYamlalways does - leaves no blank line before the closing delimiter. - The closing---is searched for from the start of the line after the opening one, so an EMPTY block (---\n---\n) exists, withfrontmatterthe empty string.
Functions
Section titled “Functions”| Function | Description |
|---|---|
| getFrontMatterInfo | Locates the frontmatter block at the start of a file’s contents: whether it exists, its text, the offsets where that text starts and ends, and the offset where the body after the closing --- begins. |