markdown-it-front-matter

Crates.iomarkdown-it-front-matter
lib.rsmarkdown-it-front-matter
version0.3.0
sourcesrc
created_at2023-06-14 00:18:35.700091
updated_at2023-08-03 16:55:49.52753
descriptionA markdown-it plugin for parsing front matter
homepage
repositoryhttps://github.com/chrisjsewell/markdown-it-plugins.rs
max_upload_size
id889567
size18,171
Chris Sewell (chrisjsewell)

documentation

README

markdown-it-front-matter.rs

crates.io

A markdown-it.rs plugin to process front matter containers.

Usage

let parser = &mut markdown_it::MarkdownIt::new();
markdown_it_front_matter::add(parser);
let ast  = parser.parse("---\nfoo: bar\n---\n");

print!("{:#?}", ast.children);
// [
//     Node {
//         children: [],
//         srcmap: Some(
//             (
//                 0,
//                 16,
//             ),
//         ),
//         ext: NodeExtSet(
//             {},
//         ),
//         attrs: [],
//         node_type: markdown_it_front_matter::FrontMatter,
//         node_value: FrontMatter {
//             content: "foo: bar\n",
//         },
//     },
// ]

Valid Front Matter

Essentially, valid front matter is a fenced block:

  • Indicated by three or more dashes: ---
  • Opening and closing fences must be the same number of dash characters
  • Opening fence must begin on the first line of the markdown string/file
  • Opening fence must not be indented
---
valid-front-matter: true
---
Commit count: 43

cargo fmt