extract
import { extract } from "jsr:@ende/front-matter/toml";function
function extract<T>(text: string): Extract<T>Extracts and parses TOML from the metadata of front matter content.
text: stringThe text to extract TOML front matter from.
Returns
The extracted TOML front matter and body content.
Example: Extract TOML front matter
import { extract } from "@ende/front-matter/toml";
import { assertEquals } from "@ende/assert";
const output = `---toml
title = "Three dashes marks the spot"
---
Hello, world!`;
const result = extract(output);
assertEquals(result, {
frontMatter: 'title = "Three dashes marks the spot"',
body: "Hello, world!",
attrs: { title: "Three dashes marks the spot" },
});