import { type Format } from "./_formats.ts"; export type { Format }; /** * Tests if a string has valid front matter. * Supports {@link https://yaml.org | YAML}, {@link https://toml.io | TOML} and * {@link https://www.json.org/ | JSON}. * * @param str String to test. * @param formats A list of formats to test for. Defaults to all supported formats. * @returns `true` if the string has valid front matter, otherwise `false`. * * @example Test for valid YAML front matter * ```ts * import { test } from "../front-matter/test.ts"; * import { assert } from "../assert/mod.ts"; * * const result = test( * `--- * title: Three dashes marks the spot * --- * `); * assert(result); * ``` * * @example Test for valid TOML front matter * ```ts * import { test } from "../front-matter/test.ts"; * import { assert } from "../assert/mod.ts"; * * const result = test( * `---toml * title = 'Three dashes followed by format marks the spot' * --- * `); * assert(result); * ``` * * @example Test for valid JSON front matter * ```ts * import { test } from "../front-matter/test.ts"; * import { assert } from "../assert/mod.ts"; * * const result = test( * `---json * {"title": "Three dashes followed by format marks the spot"} * --- * `); * assert(result); * ``` * * @example JSON front matter is not valid as YAML * ```ts * import { test } from "../front-matter/test.ts"; * import { assertFalse } from "../assert/mod.ts"; * * const result = test( * `---json * {"title": "Three dashes followed by format marks the spot"} * --- * `, ["yaml"]); * assertFalse(result); * ``` */ export declare function test(str: string, formats?: Format[]): boolean;