Expand description
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:
Structs§
- Content
- Text that is known to be non-empty and without newline characters
- Document
- A document builder
- Gemtext
- A Gemtext formatter
- Html
- An HTML formatter, available with the
html
feature - Link
- A URI with optional label
- Markdown
- A Markdown 1.0.1 formatter, available with the
markdown
feature - Preformatted
- Preformatted text with optional alt text
Enums§
- Block
- A Gemtext element
- Error
- Gemtext creation errors
- Level
- Heading level of a
Block::Heading