Expand description
This crate is intended to be used in (currently unstable) Cargo scripts. It allows you to provide structured data and configuration inside a frontmatter comment, which can be parsed and obtained using a utility macro.
§Data format support
JSON, TOML, and YAML are currently supported.
The desired format(s) must be enabled through Cargo features.
The type expected from parsing must implement Deserialize
.
The frontmatter comment is detected using the following pattern: /*${tag}\n
, where ${tag}
is json
, toml
, or yaml
(case-sensitive). The end of the frontmatter comment is detected
using \n*/\n
and must therefore not be found inside the data.
§Note
The script must not be placed directly inside the user’s home directory.
§Features
§Frontmatter format selection
One or more of these must be enabled.
json
— Enables JSON parsing.toml
— Enables TOML parsing.yaml
— Enables YAML parsing.
Macros§
- extract_
json_ frontmatter json
- Extracts, parses, and returns the JSON frontmatter.
- extract_
toml_ frontmatter toml
- Extracts, parses, and returns the TOML frontmatter.
- extract_
yaml_ frontmatter yaml
- Extracts, parses, and returns the YAML frontmatter.