aboutsummaryrefslogtreecommitdiff
path: root/examples/html.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-03-25 00:59:25 +0000
committerFuwn <[email protected]>2024-03-25 00:59:25 +0000
commit40680a3648cc7d598d428d6fe1752a2be9bfd547 (patch)
treec4ea43de3543995c0b81e1a982c8671479012fd5 /examples/html.rs
parentfeat(crate): bump version (diff)
downloadgerm-40680a3648cc7d598d428d6fe1752a2be9bfd547.tar.xz
germ-40680a3648cc7d598d428d6fe1752a2be9bfd547.zip
docs(examples): comment examples
Diffstat (limited to 'examples/html.rs')
-rw-r--r--examples/html.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/examples/html.rs b/examples/html.rs
index 541c01e..391867f 100644
--- a/examples/html.rs
+++ b/examples/html.rs
@@ -16,6 +16,9 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
+//! This example demonstrates Germ's capabilities for converting Gemtext to
+//! HTML.
+
const EXAMPLE_GEMTEXT: &str = r#"```This is alt-text
Here goes the pre-formatted text.
@@ -46,9 +49,11 @@ This is more text after a blank line.
That was a link without text."#;
fn main() {
- std::fs::write(
- "examples/convert.html",
- germ::convert::from_string(EXAMPLE_GEMTEXT, &germ::convert::Target::HTML),
- )
- .expect("could not write to file");
+ // Convert the Gemtext to HTML
+ let html =
+ germ::convert::from_string(EXAMPLE_GEMTEXT, &germ::convert::Target::HTML);
+
+ // Write the HTML to a file
+ std::fs::write("examples/convert.html", html)
+ .expect("could not write to file");
}