Unstable Rust feature "frontmatter"
Frontmatter
Lexer
FRONTMATTER →
FRONTMATTER_FENCE HORIZONTAL_WHITESPACE* INFOSTRING? HORIZONTAL_WHITESPACE* LF
( FRONTMATTER_LINE LF )*
FRONTMATTER_FENCE1 HORIZONTAL_WHITESPACE* LFFrontmatter is an optional section for content intended for external tools without requiring these tools to have full knowledge of the Rust grammar.
#!/usr/bin/env cargo --- [dependencies] fastrand = "2" --- fn main() { let num = fastrand::i32(..); println!("{num}"); }Frontmatter may only be preceded by a shebang and whitespace.
The delimiters are referred to as a fence. The opening and closing fences must be at the start of a line. They must be a matching pair of three or more hyphens (
-). A fence may be followed by horizontal whitespace.Following the opening fence may be an infostring for identifying the intention of the contained content. An infostring may be followed by horizontal whitespace.
The body of the frontmatter may contain any content except for a line starting with as many or more hyphens (
-) than in the fences.
-
The closing fence must have the same number of
-as the opening fence ↩