Function extractToml

  • Extracts and parses TOML from the metadata of front matter content.

    Type Parameters

    • T

      The type of the parsed front matter.

    Parameters

    • text: string

      The text to extract TOML front matter from.

    Returns Extract<T>

    The extracted TOML front matter and body content.

    import { extract } from "@std/front-matter/toml";
    import { assertEquals } from "@std/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" },
    });