// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.

import {
  createExtractor,
  type Extractor,
  type Parser,
} from "./create_extractor.ts";
import { parse } from "jsr:/@std/yaml@^1.0.0-rc.1/parse";

/**
 * Extracts and parses {@link https://yaml.org | YAML} from the metadata of
 * front matter content.
 *
 * @example Extract YAML front matter
 * ```ts
 * import { extract } from "@std/front-matter/yaml";
 * import { assertEquals } from "@std/assert";
 *
 * const output = `---yaml
 * 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" },
 * });
 * ```
 */
export const extract: Extractor = createExtractor({
  ["yaml"]: parse as Parser,
});

// denoCacheMetadata={"headers":{"cache-control":"public, max-age=31536000, immutable","x-jsr-backend":"modules","access-control-allow-origin":"*","etag":"\"7842c3484308fcfa20eabced1f5862ac\"","vary":"Origin","date":"Tue, 28 Jul 2026 12:31:15 GMT","cross-origin-resource-policy":"cross-origin","x-content-type-options":"nosniff","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';","set-cookie":"__cf_bm=OvBN1wNlidkmXSiHGqOwP8slEFOLBY2rwu9EqyezRSM-1785241874.992994-1.0.1.1-9bJqxpQ33I8koj9Yk.Uiw4tyZ4Y0BTqP0Vq7gzvGl429mX3QdUzQ2eKnf6wkAfJKqsipoWG4.oZ5CNZBwuF2Ym9R7NXj0xjdtrJXA1OoqfVVVeU5pwqBlw5w5SIY3kk1; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=MeYy%2BeAbpF%2Bw9P9clCJt4ZCj53%2BzO9JqHJAQyvL2B%2FnwaeSxrifPYsX1Z%2B2e%2FxW2kA5x8oh%2Fi09zgrsINn7u9AIdCUXJue6Vnt6L6Kv08YXTB8Ig%2BtlfMsU%3D\"}]}","x-robots-tag":"noindex","alt-svc":"h3=\":443\"; ma=86400","content-length":"882","server":"cloudflare","access-control-expose-headers":"*","cf-ray":"a223e656afbf7db6-LAX","content-type":"text/typescript"},"url":"https://jsr.io/@std/front-matter/0.224.3/yaml.ts","time":1785241875}