🦠 The Definitive Gemini Protocol Toolkit
gemini gemini-protocol gemtext parser zero-dependency toolkit ast converter html markdown cli networking
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: remove seldom used procedural macros

Fuwn 3854c711 1b8f4437

+41 -182
+37 -2
Cargo.toml
··· 1 1 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 2 2 3 - [workspace] 4 - members = ["crates/germ", "crates/germ-macros-impl"] 3 + [package] 4 + name = "germ" 5 + version = "0.3.8" 6 + authors = ["Fuwn <contact@fuwn.me>"] 7 + edition = "2021" 8 + description = "The Ultimate Gemini Toolkit." 9 + documentation = "https://docs.rs/germ" 10 + readme = "README.md" 11 + homepage = "https://github.com/gemrest/germ" 12 + repository = "https://github.com/gemrest/germ" 13 + license = "GPL-3.0-only" 14 + keywords = ["gemini", "parser", "lexer", "markdown", "converter"] 15 + categories = ["encoding"] 16 + 17 + [features] 18 + ast = [] 19 + convert = ["ast"] 20 + default = ["ast", "convert", "meta", "request"] 21 + macros = ["ast", "convert"] 22 + meta = [] 23 + request = ["rustls", "url", "anyhow"] 24 + quick = [] 25 + sync = ["tokio", "tokio-rustls"] 26 + 27 + [dependencies] 28 + anyhow = { version = "1.0.70", optional = true } # `Result` 29 + rustls = { version = "0.21.0", features = [ 30 + "dangerous_configuration" 31 + ], optional = true } # TLS 32 + tokio-rustls = { version = "0.24.0", optional = true } # Non-blocking TLS 33 + tokio = { version = "1.27.0", optional = true, default-features = false, features = [ 34 + "net", 35 + "io-util", 36 + "rt-multi-thread", 37 + "macros" 38 + ] } # Non-blocking I/O 39 + url = { version = "2.3.1", optional = true } # URL Validation
-13
Makefile.toml
··· 1 - # ------------ 2 - # | Wrappers | 3 - # ------------ 4 1 [tasks.fmt] 5 2 args = ["fmt"] 6 3 command = "cargo" 7 4 toolchain = "nightly" 8 - workspace = false 9 5 10 6 [tasks.check] 11 7 args = ["check", "--all-features"] 12 8 command = "cargo" 13 - workspace = false 14 9 15 10 [tasks.clippy] 16 11 args = ["clippy", "--all-features"] 17 12 command = "cargo" 18 - workspace = false 19 13 20 14 [tasks.test] 21 15 args = ["test", "--all-features"] 22 16 command = "cargo" 23 - workspace = false 24 17 25 - # ------------- 26 - # | Executors | 27 - # ------------- 28 18 [tasks.checkf] 29 19 dependencies = ["fmt", "check"] 30 - workspace = false 31 20 32 21 [tasks.checkfc] 33 22 dependencies = ["fmt", "check", "clippy"] 34 - workspace = false 35 23 36 24 [tasks.example] 37 25 args = ["run", "--example", "${@}", "--all-features"] 38 26 command = "cargo" 39 - workspace = false
+2 -1
README.md
··· 51 51 52 52 ### Examples 53 53 54 - Examples can be found within the [`examples/`](./examples) directory. 54 + Examples can be found within the 55 + [`examples/`](https://github.com/gemrest/germ/tree/main/examples) directory. 55 56 56 57 ## License 57 58
-21
crates/germ-macros-impl/Cargo.toml
··· 1 - # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 2 - 3 - [package] 4 - name = "germ-macros-impl" 5 - version = "0.1.2" 6 - authors = ["Fuwn <contact@fuwn.me>"] 7 - edition = "2021" 8 - description = "Germ Macro Implementations" 9 - documentation = "https://docs.rs/germ" 10 - readme = "../../README.md" 11 - homepage = "https://github.com/gemrest/germ" 12 - repository = "https://github.com/gemrest/germ" 13 - license = "GPL-3.0-only" 14 - keywords = ["gemini", "parser", "lexer", "markdown", "converter"] 15 - categories = ["encoding"] 16 - 17 - [lib] 18 - proc-macro = true 19 - 20 - [dependencies] 21 - quote = "1.0.18" # Quasi-quoting
-58
crates/germ-macros-impl/src/lib.rs
··· 1 - // This file is part of Germ <https://github.com/gemrest/germ>. 2 - // Copyright (C) 2022-2022 Fuwn <contact@fuwn.me> 3 - // 4 - // This program is free software: you can redistribute it and/or modify 5 - // it under the terms of the GNU General Public License as published by 6 - // the Free Software Foundation, version 3. 7 - // 8 - // This program is distributed in the hope that it will be useful, but 9 - // WITHOUT ANY WARRANTY; without even the implied warranty of 10 - // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 - // General Public License for more details. 12 - // 13 - // You should have received a copy of the GNU General Public License 14 - // along with this program. If not, see <http://www.gnu.org/licenses/>. 15 - // 16 - // Copyright (C) 2022-2022 Fuwn <contact@fuwn.me> 17 - // SPDX-License-Identifier: GPL-3.0-only 18 - 19 - #![deny( 20 - warnings, 21 - nonstandard_style, 22 - unused, 23 - future_incompatible, 24 - rust_2018_idioms, 25 - unsafe_code, 26 - clippy::all, 27 - clippy::nursery, 28 - clippy::pedantic 29 - )] 30 - #![feature(proc_macro_hygiene, proc_macro_span)] 31 - #![recursion_limit = "128"] 32 - 33 - use proc_macro::TokenStream; 34 - 35 - /// Convert Gemtext into a token tree 36 - /// 37 - /// # Panics 38 - /// 39 - /// May panic if the Gemini could not be properly handled, for any reason. 40 - #[proc_macro] 41 - pub fn gemini_to_tt(input: TokenStream) -> TokenStream { 42 - let mut tokens = input.into_iter(); 43 - let mut span = tokens.next().unwrap().span(); 44 - 45 - for token in tokens { 46 - span = span.join(token.span()).unwrap(); 47 - } 48 - 49 - let gemini = span 50 - .source_text() 51 - .unwrap() 52 - .lines() 53 - .map(|l| l.trim_start().to_string()) 54 - .collect::<Vec<String>>() 55 - .join("\n"); 56 - 57 - quote::quote!(#gemini).into() 58 - }
-35
crates/germ/Cargo.toml
··· 1 - # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 2 - 3 - [package] 4 - name = "germ" 5 - version = "0.3.8" 6 - authors = ["Fuwn <contact@fuwn.me>"] 7 - edition = "2021" 8 - description = "The Ultimate Gemini Toolkit." 9 - documentation = "https://docs.rs/germ" 10 - readme = "../../README.md" 11 - homepage = "https://github.com/gemrest/germ" 12 - repository = "https://github.com/gemrest/germ" 13 - license = "GPL-3.0-only" 14 - keywords = ["gemini", "parser", "lexer", "markdown", "converter"] 15 - categories = ["encoding"] 16 - 17 - [features] 18 - ast = [] 19 - convert = ["ast"] 20 - default = ["ast", "convert", "meta", "request"] 21 - macros = ["ast", "convert", "germ-macros-impl"] 22 - meta = [] 23 - request = ["rustls", "url", "anyhow"] 24 - quick = [] 25 - sync = ["tokio", "tokio-rustls"] 26 - 27 - [dependencies] 28 - anyhow = { version = "1.0.70", optional = true } # `Result` 29 - germ-macros-impl = { path = "../germ-macros-impl", version = "0.1.0", optional = true } # Germ's Macro Implementations 30 - rustls = { version = "0.21.0", features = [ 31 - "dangerous_configuration" 32 - ], optional = true } # TLS 33 - tokio-rustls = { version = "0.24.0", optional = true } # Non-blocking TLS 34 - tokio = { version = "1.27.0", optional = true, default-features = false, features = ["net", "io-util", "rt-multi-thread", "macros"] } # Non-blocking I/O 35 - url = { version = "2.3.1", optional = true } # URL Validation
crates/germ/examples/ast.rs examples/ast.rs
crates/germ/examples/ast_to_gemtext.rs examples/ast_to_gemtext.rs
crates/germ/examples/async_request.rs examples/async_request.rs
crates/germ/examples/convert.html examples/convert.html
crates/germ/examples/convert.md examples/convert.md
+1 -1
crates/germ/examples/html.rs examples/html.rs
··· 47 47 48 48 fn main() { 49 49 std::fs::write( 50 - "crates/germ/examples/convert.html", 50 + "examples/convert.html", 51 51 germ::convert::from_string(EXAMPLE_GEMTEXT, &germ::convert::Target::HTML), 52 52 ) 53 53 .expect("could not write to file");
+1 -1
crates/germ/examples/markdown.rs examples/markdown.rs
··· 47 47 48 48 fn main() { 49 49 std::fs::write( 50 - "crates/germ/examples/convert.md", 50 + "examples/convert.md", 51 51 germ::convert::from_string( 52 52 EXAMPLE_GEMTEXT, 53 53 &germ::convert::Target::Markdown,
crates/germ/examples/meta.rs examples/meta.rs
crates/germ/examples/request.rs examples/request.rs
crates/germ/examples/request_to_gemtext_from_ast.rs examples/request_to_gemtext_from_ast.rs
crates/germ/src/ast.rs src/ast.rs
crates/germ/src/ast/container.rs src/ast/container.rs
-14
crates/germ/src/ast/macros.rs src/ast/macros.rs
··· 28 28 /// // account for that. 29 29 /// format!("{}\n", "=> / A link!"), 30 30 /// ); 31 - /// 32 - /// /// Using raw Gemtext 33 - /// assert_eq!( 34 - /// germ::gemini_to_ast! { 35 - /// => / A link! 36 - /// => / Another link! 37 - /// } 38 - /// .to_gemtext(), 39 - /// format!("{}\n", "=> / A link!\n=> / Another link!"), 40 - /// ); 41 - /// ``` 42 31 #[macro_export] 43 32 macro_rules! gemini_to_ast { 44 33 ($gemini:expr) => { 45 34 germ::ast::Ast::from_string($gemini) 46 - }; 47 - ($($gemini:tt)*) => { 48 - germ::ast::Ast::from_string(germ_macros_impl::gemini_to_tt!($($gemini)*)); 49 35 }; 50 36 }
crates/germ/src/ast/node.rs src/ast/node.rs
crates/germ/src/convert.rs src/convert.rs
crates/germ/src/convert/html.rs src/convert/html.rs
-11
crates/germ/src/convert/macros.rs src/convert/macros.rs
··· 26 26 /// germ::gemini_to_html!("=> /to hello !"), 27 27 /// "<a href=\"/to\">hello !</a><br>", 28 28 /// ); 29 - /// 30 - /// // Using raw Gemtext 31 - /// assert_eq!( 32 - /// germ::gemini_to_html! { => /to hello ! }, 33 - /// "<a href=\"/to\">hello !</a><br>", 34 - /// ); 35 - /// ``` 36 29 #[macro_export] 37 30 macro_rules! gemini_to_html { 38 31 ($gemini:expr) => { ··· 59 52 /// germ::gemini_to_md!("=> /to hello !"), 60 53 /// "[hello !](/to)\n", 61 54 /// ); 62 - /// 63 - /// // Using raw Gemtext 64 - /// assert_eq!(germ::gemini_to_md! { => /to hello ! }, "[hello !](/to)\n",); 65 - /// ``` 66 55 #[macro_export] 67 56 macro_rules! gemini_to_md { 68 57 ($gemini:expr) => {
crates/germ/src/convert/markdown.rs src/convert/markdown.rs
crates/germ/src/lib.rs src/lib.rs
crates/germ/src/meta.rs src/meta.rs
crates/germ/src/quick.rs src/quick.rs
crates/germ/src/request.rs src/request.rs
crates/germ/src/request/response.rs src/request/response.rs
crates/germ/src/request/status.rs src/request/status.rs
crates/germ/src/request/sync.rs src/request/sync.rs
crates/germ/src/request/verifier.rs src/request/verifier.rs
-12
crates/germ/tests/ast.rs tests/ast.rs
··· 116 116 format!("{}\n", EXAMPLE_GEMTEXT), 117 117 ); 118 118 } 119 - 120 - #[test] 121 - fn gemtext_to_ast_then_ast_to_gemtext_macro_block() { 122 - assert_eq!( 123 - germ::gemini_to_ast! { 124 - => / A link! 125 - => / Another link! 126 - } 127 - .to_gemtext(), 128 - format!("{}\n", "=> / A link!\n=> / Another link!"), 129 - ); 130 - } 131 119 }
-13
crates/germ/tests/convert.rs tests/convert.rs
··· 46 46 } 47 47 48 48 #[test] 49 - fn convert_from_string_to_html_single_link_macro_block() { 50 - assert_eq!( 51 - gemini_to_html! { => /to hello ! }, 52 - "<a href=\"/to\">hello !</a><br>", 53 - ); 54 - } 55 - 56 - #[test] 57 49 fn convert_from_string_to_markdown_single_line() { 58 50 assert_eq!(from_string("hi", &Target::Markdown), "hi\n",); 59 51 } ··· 74 66 #[test] 75 67 fn convert_from_string_to_markdown_single_macro_expression() { 76 68 assert_eq!(gemini_to_md!("=> /to hello !"), "[hello !](/to)\n",); 77 - } 78 - 79 - #[test] 80 - fn convert_from_string_to_markdown_single_macro_block() { 81 - assert_eq!(gemini_to_md! { => /to hello ! }, "[hello !](/to)\n",); 82 69 } 83 70 }
crates/germ/tests/meta.rs tests/meta.rs
crates/germ/tests/quick.rs tests/quick.rs
crates/germ/tests/status.rs tests/status.rs