Compare commits

...

4 commits

Author SHA1 Message Date
01d9e06d63 Run cargo fmt 2026-04-20 22:29:53 +02:00
d26ef729eb Update edition, URL, and lints 2026-04-20 22:29:38 +02:00
f08eda2758 Satisfy clippy 2025-04-16 22:16:08 +02:00
190e00ed62 Fix typo 2025-04-16 22:12:21 +02:00
7 changed files with 27 additions and 21 deletions

View file

@ -1,10 +1,10 @@
[package] [package]
name = "el" name = "el"
version = "0.2.0" version = "0.2.0"
edition = "2021" edition = "2024"
authors = ["Garmelon <garmelon@plugh.de>"] authors = ["Garmelon <garmelon@plugh.de>"]
description = "Write and manipulate HTML elements as data" description = "Write and manipulate HTML elements as data"
repository = "https://github.com/Garmelon/el" repository = "https://git.plugh.de/Garmelon/el"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
keywords = ["html", "svg", "mathml", "hiccup"] keywords = ["html", "svg", "mathml", "hiccup"]
categories = ["web-programming", "template-engine"] categories = ["web-programming", "template-engine"]
@ -19,10 +19,12 @@ http = { version = "1.0.0", optional = true }
[lints] [lints]
rust.unsafe_code = { level = "forbid", priority = 1 } rust.unsafe_code = { level = "forbid", priority = 1 }
# Lint groups # Lint groups
rust.deprecated_safe = "warn" rust.deprecated-safe = "warn"
rust.future_incompatible = "warn" rust.future-incompatible = "warn"
rust.keyword_idents = "warn" rust.keyword-idents = "warn"
rust.rust_2018_idioms = "warn" rust.nonstandard-style = "warn"
rust.refining-impl-trait = "warn"
rust.rust-2018-idioms = "warn"
rust.unused = "warn" rust.unused = "warn"
# Individual lints # Individual lints
rust.let_underscore_drop = "warn" rust.let_underscore_drop = "warn"

View file

@ -35,7 +35,7 @@ See the top-level crate documentation for more info.
## But what about that small helper function? ## But what about that small helper function?
Here it is in full, for posteriority: Here it is in full, for posterity:
```js ```js
function el(name, attributes, ...children) { function el(name, attributes, ...children) {

View file

@ -1,5 +1,5 @@
use axum_core::response::IntoResponse; use axum_core::response::IntoResponse;
use http::{header, HeaderValue, StatusCode}; use http::{HeaderValue, StatusCode, header};
use crate::{Document, Render}; use crate::{Document, Render};

View file

@ -58,10 +58,9 @@ pub fn is_valid_raw_text(tag_name: &str, text: &str) -> bool {
// "[...] followed by characters that case-insensitively match the tag // "[...] followed by characters that case-insensitively match the tag
// name of the element [...]" // name of the element [...]"
// //
// Note: Since we know that tag names are ascii-only, we can convert // Note: Since we know that tag names are ascii-only, we can use an
// both to lowercase for a case-insensitive comparison without weird // ASCII-based case insensitive comparison without unicode shenanigans.
// unicode shenanigans. if !potential_tag_name.eq_ignore_ascii_case(tag_name) {
if potential_tag_name.to_ascii_lowercase() != tag_name.to_ascii_lowercase() {
continue; continue;
} }

View file

@ -1,4 +1,4 @@
use std::collections::{btree_map::Entry, BTreeMap, HashMap}; use std::collections::{BTreeMap, HashMap, btree_map::Entry};
/// The kind of an element. /// The kind of an element.
/// ///
@ -501,8 +501,12 @@ element_component_tuple!(C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11);
element_component_tuple!(C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12); element_component_tuple!(C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12);
element_component_tuple!(C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13); element_component_tuple!(C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13);
element_component_tuple!(C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14); element_component_tuple!(C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14);
element_component_tuple!(C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15); element_component_tuple!(
element_component_tuple!(C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16); C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15
);
element_component_tuple!(
C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16
);
/// A full HTML document including doctype. /// A full HTML document including doctype.
/// ///

View file

@ -84,7 +84,7 @@ pub use self::{element::*, render::*};
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{html::*, Attr, Content, Element, Render}; use crate::{Attr, Content, Element, Render, html::*};
#[test] #[test]
fn simple_website() { fn simple_website() {
@ -130,9 +130,11 @@ mod tests {
assert!(script("hello </script> world").render_to_string().is_err()); assert!(script("hello </script> world").render_to_string().is_err());
assert!(script("hello </ScRiPt ... world") assert!(
.render_to_string() script("hello </ScRiPt ... world")
.is_err()); .render_to_string()
.is_err()
);
} }
#[test] #[test]

View file

@ -1,9 +1,8 @@
use std::{error, fmt}; use std::{error, fmt};
use crate::{ use crate::{
check, Document, check,
element::{Content, Element, ElementKind}, element::{Content, Element, ElementKind},
Document,
}; };
/// The cause of an [`Error`]. /// The cause of an [`Error`].