6个版本 (稳定版)

1.2.1 2020年9月21日
1.1.1 2020年9月21日
1.0.1 2020年9月17日
0.1.1 2020年9月16日
0.1.0 2020年9月16日

#677 in 文本处理

Download history 8515/week @ 2024-03-14 7959/week @ 2024-03-21 7893/week @ 2024-03-28 5204/week @ 2024-04-04 6459/week @ 2024-04-11 7457/week @ 2024-04-18 6459/week @ 2024-04-25 6651/week @ 2024-05-02 9207/week @ 2024-05-09 7502/week @ 2024-05-16 6897/week @ 2024-05-23 6820/week @ 2024-05-30 8363/week @ 2024-06-06 8134/week @ 2024-06-13 8552/week @ 2024-06-20 6657/week @ 2024-06-27

33,147 每月下载量
journal_entry 中使用

MIT 许可证

34KB
960

markdown-gen

Rust包,用于生成Markdown文件

用法

let file = File::create("test.md").unwrap();
let mut md = Markdown::new(file);

md.write("Heading".heading(1)).unwrap();
md.write("Subheading".italic().heading(2)).unwrap();

md.write("bold".bold()).unwrap();

md.write("first paragraph").unwrap();
md.write(
    "Links: ".paragraph()
    .append("Rust".bold().link_to("https://rust-lang.net.cn"))
    .append(", ")
    .append("Google".italic().link_to("https://google.com"))
).unwrap();

md.write(
    List::new(true)
        .title("numbered list")
        .item("item 1")
        .item("bold".bold())
        .item(
                List::new(false)
                    .title("nested bullet list")
                    .item(
                        "bold".bold()
                            .paragraph().append(
                            "italic".italic()
                        )
                    )
           )
).unwrap();

md.write("quote".quote()).unwrap();

这将生成以下Markdown文档

# Heading
## *Subheading*
**bold**

first paragraph

Links: [**Rust**](https://rust\-lang\.org), [*Google*](https://google\.com)

numbered list
   1. item 1
   1. **bold**
   1. nested bullet list
      * **bold***italic*
>quote

您还可以将Markdown生成到 Vec<u8>

let mut md = Markdown::new(Vec::new());

md.write("test".heading(1)).unwrap();

let vec = md.into_inner();
assert_eq!(String::from_utf8(vec).unwrap(), "# test\n");

无运行时依赖