Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mrxiaozhuox/markdown-meta-parser

Parse Markdown to Json
https://github.com/mrxiaozhuox/markdown-meta-parser

Last synced: 18 days ago
JSON representation

Parse Markdown to Json

Awesome Lists containing this project

README

        

# Markdown Meta Parser

Parse Markdown Metadata

```markdown
---
title: Hello World
author: mrxiaozhuox
tags: [post, test]
released: false
---

# This is my first post!

Hello World!!
```

```rust

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());
```

```text
(
{
"author": String(
"mrxiaozhuox",
),
"tags": Array(
[
"post",
"test",
],
),
"released": Bool(
false,
),
"title": String(
"Hello World",
),
},
"\n# This is my first post!\n\nHello World!!\n",
),
```