markdown-meta-parser

Crates.iomarkdown-meta-parser
lib.rsmarkdown-meta-parser
version0.1.3
sourcesrc
created_at2022-03-18 05:06:59.608495
updated_at2022-09-09 21:41:35.841529
descriptionparse markdown metadata
homepage
repositoryhttps://github.com/mrxiaozhuox/markdown-meta-parser/
max_upload_size
id552533
size9,541
YuKun Liu (mrxiaozhuox)

documentation

README

Markdown Meta Parser

Parse Markdown Metadata

---
title: Hello World
author: mrxiaozhuox<mrxzx.info@gmail.com>
tags: [post, test]
released: false
---

# This is my first post!

Hello World!!

let content = String::from("....");

let mut type_mark = HashMap::new();

type_mark.insert("tags".into(), "array");
type_mark.insert("released".into(), "bool");


let meta = MetaData {
    content,
    required: vec!["title".to_string()],
    type_mark,
}

println!("{:#?}", meta.parse().unwrap());
(
    {
        "author": String(
            "mrxiaozhuox<mrxzx.info@gmail.com>",
        ),
        "tags": Array(
            [
                "post",
                "test",
            ],
        ),
        "released": Bool(
            false,
        ),
        "title": String(
            "Hello World",
        ),
    },
    "\n# This is my first post!\n\nHello World!!\n",
),
Commit count: 18

cargo fmt