aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-06-14 08:45:09 +0000
committerFuwn <[email protected]>2022-06-14 08:45:09 +0000
commitb5703a59c59bfe95143cf8dc6cc54f20f67fb4fd (patch)
tree44022e3944119c39df5b9082aaac3a77841c8c10
parentfix(ast): list ast construction (diff)
downloadgerm-b5703a59c59bfe95143cf8dc6cc54f20f67fb4fd.tar.xz
germ-b5703a59c59bfe95143cf8dc6cc54f20f67fb4fd.zip
feat(macros): general utility macros
-rw-r--r--Cargo.toml29
-rw-r--r--Makefile.toml7
-rw-r--r--crates/germ-macros-impl/Cargo.toml21
-rw-r--r--crates/germ-macros-impl/src/lib.rs58
-rw-r--r--crates/germ/Cargo.toml31
-rw-r--r--crates/germ/examples/ast.rs (renamed from examples/ast.rs)0
-rw-r--r--crates/germ/examples/ast_to_gemtext.rs (renamed from examples/ast_to_gemtext.rs)0
-rw-r--r--crates/germ/examples/convert.html6
-rw-r--r--crates/germ/examples/convert.md28
-rw-r--r--crates/germ/examples/html.rs (renamed from examples/html.rs)0
-rw-r--r--crates/germ/examples/markdown.rs (renamed from examples/markdown.rs)0
-rw-r--r--crates/germ/examples/meta.rs (renamed from examples/meta.rs)0
-rw-r--r--crates/germ/examples/request.rs (renamed from examples/request.rs)0
-rw-r--r--crates/germ/src/ast.rs28
-rw-r--r--crates/germ/src/ast/container.rs (renamed from src/ast.rs)158
-rw-r--r--crates/germ/src/ast/macros.rs52
-rw-r--r--crates/germ/src/ast/node.rs173
-rw-r--r--crates/germ/src/convert.rs (renamed from src/convert.rs)0
-rw-r--r--crates/germ/src/convert/html.rs (renamed from src/convert/html.rs)0
-rw-r--r--crates/germ/src/convert/markdown.rs (renamed from src/convert/markdown.rs)0
-rw-r--r--crates/germ/src/lib.rs (renamed from src/lib.rs)2
-rw-r--r--crates/germ/src/meta.rs (renamed from src/meta.rs)0
-rw-r--r--crates/germ/src/request.rs (renamed from src/request.rs)0
-rw-r--r--crates/germ/src/request/response.rs (renamed from src/request/response.rs)0
-rw-r--r--crates/germ/src/request/status.rs (renamed from src/request/status.rs)0
-rw-r--r--crates/germ/src/request/verifier.rs (renamed from src/request/verifier.rs)0
-rw-r--r--crates/germ/tests/ast.rs (renamed from tests/ast.rs)22
-rw-r--r--crates/germ/tests/convert.rs (renamed from tests/convert.rs)0
-rw-r--r--crates/germ/tests/meta.rs (renamed from tests/meta.rs)0
-rw-r--r--crates/germ/tests/status.rs (renamed from tests/status.rs)0
-rw-r--r--rust-toolchain.toml2
31 files changed, 431 insertions, 186 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 39a0401..550daba 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,29 +1,4 @@
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-[package]
-name = "germ"
-version = "0.2.8"
-authors = ["Fuwn <[email protected]>"]
-edition = "2021"
-description = "The Ultimate Gemini Toolkit."
-documentation = "https://docs.rs/germ"
-readme = "README.md"
-homepage = "https://github.com/gemrest/germ"
-repository = "https://github.com/gemrest/germ"
-license = "GPL-3.0-only"
-keywords = ["gemini", "parser", "lexer", "markdown", "converter"]
-categories = ["encoding"]
-
-[features]
-ast = []
-convert = ["ast"]
-default = ["ast", "convert", "meta", "request"]
-meta = []
-request = ["rustls", "url", "anyhow"]
-
-[dependencies]
-anyhow = { version = "1.0.57", optional = true } # `Result`
-rustls = { version = "0.20.5", features = [
- "dangerous_configuration"
-], optional = true } # TLS
-url = { version = "2.2.2", optional = true } # URL Validation
+[workspace]
+members = ["crates/germ", "crates/germ-macros-impl"]
diff --git a/Makefile.toml b/Makefile.toml
index 6cc0251..8d72151 100644
--- a/Makefile.toml
+++ b/Makefile.toml
@@ -5,28 +5,35 @@
args = ["fmt"]
command = "cargo"
toolchain = "nightly"
+workspace = false
[tasks.check]
args = ["check", "--all-features"]
command = "cargo"
+workspace = false
[tasks.clippy]
args = ["clippy", "--all-features"]
command = "cargo"
+workspace = false
[tasks.test]
args = ["test", "--all-features"]
command = "cargo"
+workspace = false
# -------------
# | Executors |
# -------------
[tasks.checkf]
dependencies = ["fmt", "check"]
+workspace = false
[tasks.checkfc]
dependencies = ["fmt", "check", "clippy"]
+workspace = false
[tasks.example]
args = ["run", "--example", "${@}", "--all-features"]
command = "cargo"
+workspace = false
diff --git a/crates/germ-macros-impl/Cargo.toml b/crates/germ-macros-impl/Cargo.toml
new file mode 100644
index 0000000..18c41ac
--- /dev/null
+++ b/crates/germ-macros-impl/Cargo.toml
@@ -0,0 +1,21 @@
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[package]
+name = "germ-macros-impl"
+version = "0.2.8"
+authors = ["Fuwn <[email protected]>"]
+edition = "2021"
+description = "The Ultimate Gemini Toolkit."
+documentation = "https://docs.rs/germ"
+readme = "README.md"
+homepage = "https://github.com/gemrest/germ"
+repository = "https://github.com/gemrest/germ"
+license = "GPL-3.0-only"
+keywords = ["gemini", "parser", "lexer", "markdown", "converter"]
+categories = ["encoding"]
+
+[lib]
+proc-macro = true
+
+[dependencies]
+quote = "1.0.18" # Quasi-quoting
diff --git a/crates/germ-macros-impl/src/lib.rs b/crates/germ-macros-impl/src/lib.rs
new file mode 100644
index 0000000..30fdd81
--- /dev/null
+++ b/crates/germ-macros-impl/src/lib.rs
@@ -0,0 +1,58 @@
+// This file is part of Germ <https://github.com/gemrest/germ>.
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 3.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+// SPDX-License-Identifier: GPL-3.0-only
+
+#![deny(
+ warnings,
+ nonstandard_style,
+ unused,
+ future_incompatible,
+ rust_2018_idioms,
+ unsafe_code,
+ clippy::all,
+ clippy::nursery,
+ clippy::pedantic
+)]
+#![feature(proc_macro_hygiene, proc_macro_span)]
+#![recursion_limit = "128"]
+
+use proc_macro::TokenStream;
+
+/// Convert Gemtext into a token tree
+///
+/// # Panics
+///
+/// May panic if the Gemini could not be properly handled, for any reason.
+#[proc_macro]
+pub fn gemini_to_tt(input: TokenStream) -> TokenStream {
+ let mut tokens = input.into_iter();
+ let mut span = tokens.next().unwrap().span();
+
+ for token in tokens {
+ span = span.join(token.span()).unwrap();
+ }
+
+ let gemini = span
+ .source_text()
+ .unwrap()
+ .lines()
+ .map(|l| l.trim_start().to_string())
+ .collect::<Vec<String>>()
+ .join("\n");
+
+ quote::quote!(#gemini).into()
+}
diff --git a/crates/germ/Cargo.toml b/crates/germ/Cargo.toml
new file mode 100644
index 0000000..105719d
--- /dev/null
+++ b/crates/germ/Cargo.toml
@@ -0,0 +1,31 @@
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[package]
+name = "germ"
+version = "0.2.8"
+authors = ["Fuwn <[email protected]>"]
+edition = "2021"
+description = "The Ultimate Gemini Toolkit."
+documentation = "https://docs.rs/germ"
+readme = "../../../README.md"
+homepage = "https://github.com/gemrest/germ"
+repository = "https://github.com/gemrest/germ"
+license = "GPL-3.0-only"
+keywords = ["gemini", "parser", "lexer", "markdown", "converter"]
+categories = ["encoding"]
+
+[features]
+ast = []
+convert = ["ast"]
+default = ["ast", "convert", "meta", "request"]
+macros = ["ast", "convert", "meta"]
+meta = []
+request = ["rustls", "url", "anyhow"]
+
+[dependencies]
+anyhow = { version = "1.0.57", optional = true } # `Result`
+germ-macros-impl = { path = "../germ-macros-impl" } # Germ's Macro Implementations
+rustls = { version = "0.20.5", features = [
+ "dangerous_configuration"
+], optional = true } # TLS
+url = { version = "2.2.2", optional = true } # URL Validation
diff --git a/examples/ast.rs b/crates/germ/examples/ast.rs
index 884bd91..884bd91 100644
--- a/examples/ast.rs
+++ b/crates/germ/examples/ast.rs
diff --git a/examples/ast_to_gemtext.rs b/crates/germ/examples/ast_to_gemtext.rs
index 5ceef21..5ceef21 100644
--- a/examples/ast_to_gemtext.rs
+++ b/crates/germ/examples/ast_to_gemtext.rs
diff --git a/crates/germ/examples/convert.html b/crates/germ/examples/convert.html
new file mode 100644
index 0000000..cdfde66
--- /dev/null
+++ b/crates/germ/examples/convert.html
@@ -0,0 +1,6 @@
+<pre>Here goes the pre-formatted text.
+
+This continues the pre-formatted text on a new line after a blank line.
+</pre><h1>This is a heading</h1><p>This is some text.</p><p>This is more text after a blank line.</p><ul><li>This is a single list item.</li>
+<li>This is the next list item.</li></ul><ul><li>This is a new list.</li>
+<li>This is the next item on the new list.</li></ul><h2>This is a sub-heading</h2><blockquote>This is a blockquote.</blockquote><h3>This is a sub-sub-heading.</h3><a href="gemini://gem.rest/">This is a link to GemRest</a><br><a href="/somewhere">/somewhere</a><br><p>That was a link without text.</p> \ No newline at end of file
diff --git a/crates/germ/examples/convert.md b/crates/germ/examples/convert.md
new file mode 100644
index 0000000..ea553ee
--- /dev/null
+++ b/crates/germ/examples/convert.md
@@ -0,0 +1,28 @@
+```This is alt-text
+Here goes the pre-formatted text.
+
+This continues the pre-formatted text on a new line after a blank line.
+```
+
+# This is a heading
+
+This is some text.
+
+This is more text after a blank line.
+
+- This is a single list item.
+- This is the next list item.
+
+- This is a new list.
+- This is the next item on the new list.
+
+## This is a sub-heading
+
+> This is a blockquote.
+
+### This is a sub-sub-heading.
+
+[This is a link to GemRest](gemini://gem.rest/)
+</somewhere>
+
+That was a link without text.
diff --git a/examples/html.rs b/crates/germ/examples/html.rs
index 541c01e..541c01e 100644
--- a/examples/html.rs
+++ b/crates/germ/examples/html.rs
diff --git a/examples/markdown.rs b/crates/germ/examples/markdown.rs
index c14cdc5..c14cdc5 100644
--- a/examples/markdown.rs
+++ b/crates/germ/examples/markdown.rs
diff --git a/examples/meta.rs b/crates/germ/examples/meta.rs
index a9f4077..a9f4077 100644
--- a/examples/meta.rs
+++ b/crates/germ/examples/meta.rs
diff --git a/examples/request.rs b/crates/germ/examples/request.rs
index e33710f..e33710f 100644
--- a/examples/request.rs
+++ b/crates/germ/examples/request.rs
diff --git a/crates/germ/src/ast.rs b/crates/germ/src/ast.rs
new file mode 100644
index 0000000..8c00b52
--- /dev/null
+++ b/crates/germ/src/ast.rs
@@ -0,0 +1,28 @@
+// This file is part of Germ <https://github.com/gemrest/germ>.
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 3.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+// SPDX-License-Identifier: GPL-3.0-only
+
+//! Build AST trees from Gemtext
+
+mod container;
+mod node;
+
+#[cfg(feature = "macros")]
+mod macros;
+
+pub use container::Ast;
+pub use node::Node;
diff --git a/src/ast.rs b/crates/germ/src/ast/container.rs
index eae0683..d9e4d18 100644
--- a/src/ast.rs
+++ b/crates/germ/src/ast/container.rs
@@ -16,163 +16,7 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-//! Build AST trees from Gemtext
-
-/// A Gemtext AST node.
-///
-/// Each Gemtext line is a `Node`, and some lines can even be grouped together,
-/// such as the `Node::List` `Node`!
-///
-/// # Gemtext Resources
-///
-/// - [Gemtext Documentation](https://gemini.circumlunar.space/docs/gemtext.gmi)
-/// - [Gemtext Cheatsheet](https://gemini.circumlunar.space/docs/cheatsheet.gmi).
-/// - [Gemini Specification](https://gemini.circumlunar.space/docs/specification.gmi).
-#[derive(Debug, PartialEq)]
-pub enum Node {
- /// A text line
- ///
- /// # Example
- ///
- /// ```gemini
- /// This is a text line
- /// ```
- Text(String),
- /// A link line
- ///
- /// # Examples
- ///
- /// ```gemini
- /// => /this-is-the-to This is the text
- ///
- /// => gemini://to.somewhere.link
- /// ```
- Link {
- /// The location that a link line is pointing to
- ///
- /// # Examples
- ///
- /// ```gemini
- /// => /this-is-the-to This is the text
- ///
- /// => gemini://to.somewhere.link
- /// ```
- to: String,
- /// The text a link line *may* have
- ///
- /// # Examples
- ///
- /// ```gemini
- /// => /this-is-the-to This line has text, unlike the next one.
- ///
- /// => gemini://to.somewhere.link
- /// ```
- text: Option<String>,
- },
- /// A heading line
- ///
- /// # Examples
- ///
- /// ```gemini
- /// # This is a heading
- ///
- /// ## This is a sub-heading
- ///
- /// ### This is a sub-sub-heading
- /// ```
- Heading {
- /// The level of a heading
- ///
- /// # Examples
- ///
- /// ```gemini
- /// # This is a level 1 heading
- ///
- /// ## This is a level 2 sub-heading
- ///
- /// ### This is a level 3 sub-sub-heading
- /// ```
- level: usize,
- /// The text of a heading
- ///
- /// # Examples
- ///
- /// ```gemini
- /// # This is the headings text
- ///
- /// # This is also the headings text
- /// ```
- text: String,
- },
- /// A collection of sequential list item lines
- ///
- /// # Examples
- ///
- /// ```gemini
- /// * These are
- /// * sequential list
- /// * items.
- /// ```
- List(Vec<String>),
- /// A blockquote line
- ///
- /// # Examples
- ///
- /// ```gemini
- /// > This is a blockquote line
- ///
- /// > This is also a blockquote line
- /// ```
- Blockquote(String),
- /// A preformatted block
- ///
- /// # Examples
- ///
- /// Try to ignore the leading backslash in-front of the triple backticks,
- /// they are there to not confuse the Markdown engine.
- ///
- /// ```gemini
- /// \```This is the alt-text
- /// This is the preformatted block
- ///
- /// This is the rest of the preformatted block
- /// \```
- /// ```
- PreformattedText {
- /// A preformatted blocks alt-text
- ///
- /// # Examples
- ///
- /// Try to ignore the leading backslash in-front of the triple backticks,
- /// they are there to not confuse the Markdown engine.
- ///
- /// ```gemini
- /// \```This is the alt-text
- /// This is the preformatted block
- ///
- /// This is the rest of the preformatted block
- /// \```
- /// ```
- alt_text: Option<String>,
- /// A preformatted blocks content
- ///
- /// # Examples
- ///
- /// Try to ignore the leading backslash in-front of the triple backticks,
- /// they are there to not confuse the Markdown engine.
- ///
- /// ```gemini
- /// \```This is the alt-text
- /// This is the preformatted blocks content
- ///
- /// This is the rest of the preformatted blocks content
- /// \```
- /// ```
- text: String,
- },
- /// A whitespace line, a line which contains nothing but whitespace.
- Whitespace,
-}
+use super::Node;
/// An AST structure which contains an AST tree
///
diff --git a/crates/germ/src/ast/macros.rs b/crates/germ/src/ast/macros.rs
new file mode 100644
index 0000000..b072daa
--- /dev/null
+++ b/crates/germ/src/ast/macros.rs
@@ -0,0 +1,52 @@
+// This file is part of Germ <https://github.com/gemrest/germ>.
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 3.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+// SPDX-License-Identifier: GPL-3.0-only
+
+//! Macros to aid with various Germ-related functionalities.
+
+/// Convert a Gemini token tree into an `Ast`
+///
+/// # Example
+///
+/// ```rust
+/// // Using a value
+/// assert_eq!(
+/// germ::gemini_to_ast!("=> / A link!").to_gemtext(),
+/// // `to_gemtext` appends a newline to all responses, so let's make sure we
+/// // account for that.
+/// format!("{}\n", "=> / A link!"),
+/// );
+///
+/// /// Using raw Gemtext
+/// assert_eq!(
+/// germ::gemini_to_ast! {
+/// => / A link!
+/// => / Another link!
+/// }
+/// .to_gemtext(),
+/// format!("{}\n", "=> / A link!\n=> / Another link!"),
+/// );
+/// ```
+#[macro_export]
+macro_rules! gemini_to_ast {
+ ($gemini:expr) => {
+ germ::ast::Ast::from_string($gemini)
+ };
+ ($($gemini:tt)*) => {
+ germ::ast::Ast::from_string(germ_macros_impl::gemini_to_tt!($($gemini)*));
+ };
+}
diff --git a/crates/germ/src/ast/node.rs b/crates/germ/src/ast/node.rs
new file mode 100644
index 0000000..04296ff
--- /dev/null
+++ b/crates/germ/src/ast/node.rs
@@ -0,0 +1,173 @@
+// This file is part of Germ <https://github.com/gemrest/germ>.
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 3.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+// Copyright (C) 2022-2022 Fuwn <[email protected]>
+// SPDX-License-Identifier: GPL-3.0-only
+
+/// A Gemtext AST node.
+///
+/// Each Gemtext line is a `Node`, and some lines can even be grouped together,
+/// such as the `Node::List` `Node`!
+///
+/// # Gemtext Resources
+///
+/// - [Gemtext Documentation](https://gemini.circumlunar.space/docs/gemtext.gmi)
+/// - [Gemtext Cheatsheet](https://gemini.circumlunar.space/docs/cheatsheet.gmi).
+/// - [Gemini Specification](https://gemini.circumlunar.space/docs/specification.gmi).
+#[derive(Debug, PartialEq)]
+pub enum Node {
+ /// A text line
+ ///
+ /// # Example
+ ///
+ /// ```gemini
+ /// This is a text line
+ /// ```
+ Text(String),
+ /// A link line
+ ///
+ /// # Examples
+ ///
+ /// ```gemini
+ /// => /this-is-the-to This is the text
+ ///
+ /// => gemini://to.somewhere.link
+ /// ```
+ Link {
+ /// The location that a link line is pointing to
+ ///
+ /// # Examples
+ ///
+ /// ```gemini
+ /// => /this-is-the-to This is the text
+ ///
+ /// => gemini://to.somewhere.link
+ /// ```
+ to: String,
+ /// The text a link line *may* have
+ ///
+ /// # Examples
+ ///
+ /// ```gemini
+ /// => /this-is-the-to This line has text, unlike the next one.
+ ///
+ /// => gemini://to.somewhere.link
+ /// ```
+ text: Option<String>,
+ },
+ /// A heading line
+ ///
+ /// # Examples
+ ///
+ /// ```gemini
+ /// # This is a heading
+ ///
+ /// ## This is a sub-heading
+ ///
+ /// ### This is a sub-sub-heading
+ /// ```
+ Heading {
+ /// The level of a heading
+ ///
+ /// # Examples
+ ///
+ /// ```gemini
+ /// # This is a level 1 heading
+ ///
+ /// ## This is a level 2 sub-heading
+ ///
+ /// ### This is a level 3 sub-sub-heading
+ /// ```
+ level: usize,
+ /// The text of a heading
+ ///
+ /// # Examples
+ ///
+ /// ```gemini
+ /// # This is the headings text
+ ///
+ /// # This is also the headings text
+ /// ```
+ text: String,
+ },
+ /// A collection of sequential list item lines
+ ///
+ /// # Examples
+ ///
+ /// ```gemini
+ /// * These are
+ /// * sequential list
+ /// * items.
+ /// ```
+ List(Vec<String>),
+ /// A blockquote line
+ ///
+ /// # Examples
+ ///
+ /// ```gemini
+ /// > This is a blockquote line
+ ///
+ /// > This is also a blockquote line
+ /// ```
+ Blockquote(String),
+ /// A preformatted block
+ ///
+ /// # Examples
+ ///
+ /// Try to ignore the leading backslash in-front of the triple backticks,
+ /// they are there to not confuse the Markdown engine.
+ ///
+ /// ```gemini
+ /// \```This is the alt-text
+ /// This is the preformatted block
+ ///
+ /// This is the rest of the preformatted block
+ /// \```
+ /// ```
+ PreformattedText {
+ /// A preformatted blocks alt-text
+ ///
+ /// # Examples
+ ///
+ /// Try to ignore the leading backslash in-front of the triple backticks,
+ /// they are there to not confuse the Markdown engine.
+ ///
+ /// ```gemini
+ /// \```This is the alt-text
+ /// This is the preformatted block
+ ///
+ /// This is the rest of the preformatted block
+ /// \```
+ /// ```
+ alt_text: Option<String>,
+ /// A preformatted blocks content
+ ///
+ /// # Examples
+ ///
+ /// Try to ignore the leading backslash in-front of the triple backticks,
+ /// they are there to not confuse the Markdown engine.
+ ///
+ /// ```gemini
+ /// \```This is the alt-text
+ /// This is the preformatted blocks content
+ ///
+ /// This is the rest of the preformatted blocks content
+ /// \```
+ /// ```
+ text: String,
+ },
+ /// A whitespace line, a line which contains nothing but whitespace.
+ Whitespace,
+}
diff --git a/src/convert.rs b/crates/germ/src/convert.rs
index c68696e..c68696e 100644
--- a/src/convert.rs
+++ b/crates/germ/src/convert.rs
diff --git a/src/convert/html.rs b/crates/germ/src/convert/html.rs
index 7b1cafe..7b1cafe 100644
--- a/src/convert/html.rs
+++ b/crates/germ/src/convert/html.rs
diff --git a/src/convert/markdown.rs b/crates/germ/src/convert/markdown.rs
index a38da9f..a38da9f 100644
--- a/src/convert/markdown.rs
+++ b/crates/germ/src/convert/markdown.rs
diff --git a/src/lib.rs b/crates/germ/src/lib.rs
index 83aef0e..1289751 100644
--- a/src/lib.rs
+++ b/crates/germ/src/lib.rs
@@ -27,7 +27,7 @@
clippy::nursery,
clippy::pedantic
)]
-#![doc = include_str!("../README.md")]
+#![doc = include_str!("../../../README.md")]
#![recursion_limit = "128"]
#[cfg(feature = "ast")]
diff --git a/src/meta.rs b/crates/germ/src/meta.rs
index f8a9dfb..f8a9dfb 100644
--- a/src/meta.rs
+++ b/crates/germ/src/meta.rs
diff --git a/src/request.rs b/crates/germ/src/request.rs
index 07d3552..07d3552 100644
--- a/src/request.rs
+++ b/crates/germ/src/request.rs
diff --git a/src/request/response.rs b/crates/germ/src/request/response.rs
index 5e1f436..5e1f436 100644
--- a/src/request/response.rs
+++ b/crates/germ/src/request/response.rs
diff --git a/src/request/status.rs b/crates/germ/src/request/status.rs
index f46059a..f46059a 100644
--- a/src/request/status.rs
+++ b/crates/germ/src/request/status.rs
diff --git a/src/request/verifier.rs b/crates/germ/src/request/verifier.rs
index d6511c3..d6511c3 100644
--- a/src/request/verifier.rs
+++ b/crates/germ/src/request/verifier.rs
diff --git a/tests/ast.rs b/crates/germ/tests/ast.rs
index 5f6cd5c..302b9c9 100644
--- a/tests/ast.rs
+++ b/crates/germ/tests/ast.rs
@@ -106,4 +106,26 @@ That was a link without text."#;
format!("{}\n", EXAMPLE_GEMTEXT),
);
}
+
+ #[test]
+ fn gemtext_to_ast_then_ast_to_gemtext_macro() {
+ assert_eq!(
+ germ::gemini_to_ast!(EXAMPLE_GEMTEXT).to_gemtext(),
+ // `to_gemtext` appends a newline to all responses, so let's make sure we
+ // account for that.
+ format!("{}\n", EXAMPLE_GEMTEXT),
+ );
+ }
+
+ #[test]
+ fn gemtext_to_ast_then_ast_to_gemtext_macro_simple() {
+ assert_eq!(
+ germ::gemini_to_ast! {
+ => / A link!
+ => / Another link!
+ }
+ .to_gemtext(),
+ format!("{}\n", "=> / A link!\n=> / Another link!"),
+ );
+ }
}
diff --git a/tests/convert.rs b/crates/germ/tests/convert.rs
index 40f337d..40f337d 100644
--- a/tests/convert.rs
+++ b/crates/germ/tests/convert.rs
diff --git a/tests/meta.rs b/crates/germ/tests/meta.rs
index 70c8adc..70c8adc 100644
--- a/tests/meta.rs
+++ b/crates/germ/tests/meta.rs
diff --git a/tests/status.rs b/crates/germ/tests/status.rs
index 51f3f66..51f3f66 100644
--- a/tests/status.rs
+++ b/crates/germ/tests/status.rs
diff --git a/rust-toolchain.toml b/rust-toolchain.toml
index 292fe49..5d56faf 100644
--- a/rust-toolchain.toml
+++ b/rust-toolchain.toml
@@ -1,2 +1,2 @@
[toolchain]
-channel = "stable"
+channel = "nightly"