diff --git a/Cargo.lock b/Cargo.lock index e28f29f..752e85f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -655,7 +655,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "html-renderer" -version = "0.1.0" +version = "1.0.0" dependencies = [ "chromiumoxide", "futures", diff --git a/Cargo.toml b/Cargo.toml index 82751b9..492c801 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,14 @@ [package] name = "html-renderer" -version = "0.1.0" +version = "1.0.0" edition = "2024" +license = "MIT" +readme = "README.md" +repository = "https://github.com/f-code-club/html-renderer" +homepage = "https://github.com/f-code-club/html-renderer" +description = """ +HTML renderer project written in Rust +""" [dependencies] chromiumoxide = "0.9.1" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5820abf --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2026 akagiyuu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..d50caf2 --- /dev/null +++ b/README.md @@ -0,0 +1,74 @@ +# HTML Renderer + +HTML renderer project written in Rust + +## Usage +```rust +const HTML: &str = r#" +
+
+
+ +"#; +const EXPECTED: &[u8] = include_bytes!("expected.png"); + +#[tokio::main] +pub async fn main() { + let expected = image::load_from_memory(EXPECTED).unwrap(); + let rendered = html_renderer::render(HTML, expected.width(), expected.height()) + .await + .unwrap(); + let rendered = image::load_from_memory(&rendered).unwrap(); + + let score = image_compare::rgba_hybrid_compare(&expected.into_rgba8(), &rendered.into_rgba8()) + .unwrap() + .score; + println!("Score: {score}"); +} +``` diff --git a/examples/basic.rs b/examples/basic.rs new file mode 100644 index 0000000..65d7788 --- /dev/null +++ b/examples/basic.rs @@ -0,0 +1,67 @@ +const HTML: &str = r#" +
+
+
+ +"#; +const EXPECTED: &[u8] = include_bytes!("expected.png"); + +#[tokio::main] +pub async fn main() { + let expected = image::load_from_memory(EXPECTED).unwrap(); + let rendered = html_renderer::render(HTML, expected.width(), expected.height()) + .await + .unwrap(); + let rendered = image::load_from_memory(&rendered).unwrap(); + + let score = image_compare::rgba_hybrid_compare(&expected.into_rgba8(), &rendered.into_rgba8()) + .unwrap() + .score; + println!("Score: {score}"); +} diff --git a/examples/expected.png b/examples/expected.png new file mode 100644 index 0000000..59bb14a Binary files /dev/null and b/examples/expected.png differ diff --git a/src/lib.rs b/src/lib.rs index 76be417..0eaf570 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,7 +19,7 @@ pub async fn render(html: &str, width: u32, height: u32) -> chromiumoxide::error .await?; tokio::spawn(async move { loop { - let _ = handler.next().await.unwrap(); + let _ = handler.next().await; } });