// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// Copyright (c) Jason Campbell. MIT license

/**
 * Extracts
 * {@link https://daily-dev-tips.com/posts/what-exactly-is-frontmatter/ | front matter}
 * from strings. Adapted from
 * {@link https://github.com/jxson/front-matter/blob/36f139ef797bd9e5196a9ede03ef481d7fbca18e/index.js | jxson/front-matter}.
 *
 * ## Supported formats
 *
 * ### JSON
 *
 * ```ts
 * import { test, extractJson } from "@std/front-matter";
 * import { assertEquals } from "@std/assert";
 *
 * const str = "---json\n{\"and\": \"this\"}\n---\ndeno is awesome";
 *
 * assertEquals(test(str), true);
 * assertEquals(extractJson(str), {
 *   frontMatter: "{\"and\": \"this\"}",
 *   body: "deno is awesome",
 *   attrs: { and: "this" }
 * });
 * ```
 *
 * {@linkcode extractJson | extract} and {@linkcode test} support the following
 * delimiters.
 *
 * ```markdown
 * ---json
 * {
 *   "and": "this"
 * }
 * ---
 * ```
 *
 * ```markdown
 * {
 *   "is": "JSON"
 * }
 * ```
 *
 * ### TOML
 *
 * ```ts
 * import { test, extractToml } from "@std/front-matter";
 * import { assertEquals } from "@std/assert";
 *
 * const str = "---toml\nmodule = 'front_matter'\n---\ndeno is awesome";
 *
 * assertEquals(test(str), true);
 * assertEquals(extractToml(str), {
 *   frontMatter: "module = 'front_matter'",
 *   body: "deno is awesome",
 *   attrs: { module: "front_matter" }
 * });
 * ```
 *
 * {@linkcode extractToml | extract} and {@linkcode test} support the following
 * delimiters.
 *
 * ```markdown
 * ---toml
 * this = 'is'
 * ---
 * ```
 *
 * ```markdown
 * = toml =
 * parsed = 'as'
 * toml = 'data'
 * = toml =
 * ```
 *
 * ```markdown
 * +++
 * is = 'that'
 * not = 'cool?'
 * +++
 * ```
 *
 * ### YAML
 *
 * ```ts
 * import { test, extractYaml } from "@std/front-matter";
 * import { assertEquals } from "@std/assert";
 *
 * const str = "---yaml\nmodule: front_matter\n---\ndeno is awesome";
 *
 * assertEquals(test(str), true);
 * assertEquals(extractYaml(str), {
 *   frontMatter: "module: front_matter",
 *   body: "deno is awesome",
 *   attrs: { module: "front_matter" }
 * });
 * ```
 *
 * {@linkcode extractYaml | extract} and {@linkcode test} support the following
 * delimiters.
 *
 * ```front_matter
 * ---
 * these: are
 * ---
 * ```
 *
 * ```markdown
 * ---yaml
 * all: recognized
 * ---
 * ```
 *
 * ```markdown
 * = yaml =
 * as: yaml
 * = yaml =
 * ```
 *
 * @module
 */
import { extract as extractJson } from "./json.ts";
import { extract as extractToml } from "./toml.ts";
import { extract as extractYaml } from "./yaml.ts";

export * from "./create_extractor.ts";
export * from "./test.ts";

export { extractJson, extractToml, extractYaml };

// denoCacheMetadata={"headers":{"content-type":"text/typescript","server":"cloudflare","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=WP6zjUuzlAJaHcDOVD%2Bsn6w%2FQn3aGMsVdnR%2BBvQWDX5HTm7X5jXDW7W43IHjRbd5hUXEkdVxgeTWYzgLp%2F17DH9PUSKz8GfkpFEC%2Bl0PnHBx8pk%2FN7wC43M%3D\"}]}","cross-origin-resource-policy":"cross-origin","content-security-policy":"default-src 'none'; script-src 'none'; style-src 'none'; img-src 'none'; font-src 'none'; connect-src 'none'; frame-src 'none'; object-src 'none'; frame-ancestors 'none'; sandbox; form-action 'none';","x-jsr-backend":"modules","vary":"Origin","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","content-length":"2713","alt-svc":"h3=\":443\"; ma=86400","cache-control":"public, max-age=31536000, immutable","set-cookie":"__cf_bm=k8Mj7g2nH.EO3jlGSmAohw3e0LPrtzul8UwxiJfnB7c-1785241874.9325771-1.0.1.1-pr3VHR7wulAkITN_m7CcZYXo7S7.GtMUSEMQ9K5LKd0ZEWgsCj6JSHLzSBvZubCWk5rkRYLDKDVqXPN2Blg1wiq8q3wRBDpeUnZqeKBs439Pz2nnSTXivEn9Wh_nQTYy; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","access-control-allow-origin":"*","etag":"\"e720fc74c94f30ae838a073e10be7f2c\"","cf-ray":"a223e6564e877db6-LAX","access-control-expose-headers":"*","date":"Tue, 28 Jul 2026 12:31:15 GMT","x-robots-tag":"noindex","x-content-type-options":"nosniff"},"url":"https://jsr.io/@std/front-matter/0.224.3/mod.ts","time":1785241875}