Function test
- test(str, formats?): boolean
Parameters
- str: string
String to test.
Optionalformats: Format[]A list of formats to test for. Defaults to all supported formats.
Returns boolean
trueif the string has valid front matter, otherwisefalse.Example: Test for valid YAML front matter
import { test } from "@std/front-matter/test";
import { assert } from "@std/assert";
const result = test(
`---
title: Three dashes marks the spot
---
`);
assert(result);Example: Test for valid TOML front matter
import { test } from "@std/front-matter/test";
import { assert } from "@std/assert";
const result = test(
`---toml
title = 'Three dashes followed by format marks the spot'
---
`);
assert(result);- str: string
Tests if a string has valid front matter. Supports YAML, TOML and JSON.