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

#2988 in Parser implementations

Download history 75/week @ 2024-07-29 32/week @ 2024-08-05 47/week @ 2024-08-12 22/week @ 2024-08-19 39/week @ 2024-08-26 23/week @ 2024-09-02 28/week @ 2024-09-09 19/week @ 2024-09-16 41/week @ 2024-09-23 27/week @ 2024-09-30 23/week @ 2024-10-07 13/week @ 2024-10-14 163/week @ 2024-10-21 95/week @ 2024-10-28 14/week @ 2024-11-04 2/week @ 2024-11-11

275 downloads per month
Used in mdbook-journal

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–13MB
~191K SLoC