3 releases

0.1.2 Aug 22, 2022
0.1.1 May 4, 2022
0.1.0 Apr 28, 2022

#508 in Template engine

Download history 10/week @ 2024-02-21 11/week @ 2024-02-28 17/week @ 2024-03-27 35/week @ 2024-04-03

52 downloads per month

MIT/Apache

24KB
453 lines

mdiu

Build documents with Gemtext

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Build documents with Gemtext

mdiu provides a correct and flexible approach to creating small documents with Gemtext.

Named after the Manual Data Insertion Unit, part of Gemini's on-board computer.

Examples

Create a document with a builder

use mdiu::{Document, Gemtext, ToMarkup};

let gemtext = Document::new()
    .h1("my gemlog")
    .text("welcome")
    .build()?
    .to_markup::<Gemtext>();

assert_eq!(gemtext, "# my gemlog\nwelcome\n");

Create a document block by block

use mdiu::{Block, Content, Gemtext, Level, Markup};

let h1 = Block::Heading(Level::One, "my gemlog".parse()?);
let text = Block::Text(Content::new("welcome")?);
let doc = vec![h1, text];

let gemtext = <Gemtext>::markup(&doc);

assert_eq!(gemtext, "# my gemlog\nwelcome\n");

Features

Formatting to Gemtext is supported by default. Additional features are available for the following formats:

  • html
  • markdown

A Gemtext parsing feature is planned but not yet implemented.

Alternatives

While mdiu only covers Gemtext, the following crates cover the full Gemini protocol:

Dependencies

~570KB