4 releases (2 breaking)

0.3.0 Aug 3, 2023
0.2.0 Jun 17, 2023
0.1.1 Jun 14, 2023
0.1.0 Jun 14, 2023

#2965 in Parser implementations

Download history 38/week @ 2024-03-11 20/week @ 2024-03-18 11/week @ 2024-03-25 44/week @ 2024-04-01 16/week @ 2024-04-08 29/week @ 2024-04-15 20/week @ 2024-04-22 10/week @ 2024-04-29 24/week @ 2024-05-06 15/week @ 2024-05-13 8/week @ 2024-05-20 26/week @ 2024-05-27 21/week @ 2024-06-03 19/week @ 2024-06-10 32/week @ 2024-06-17 20/week @ 2024-06-24

93 downloads per month

Apache-2.0

7KB
59 lines

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
---

Dependencies

~5–7MB
~161K SLoC