remove treehouse-format crate and collapse everything into src

This commit is contained in:
りき萌 2025-07-10 16:50:41 +02:00
parent ca127a9411
commit b792688776
66 changed files with 145 additions and 112 deletions

40
src/html.rs Normal file
View file

@ -0,0 +1,40 @@
use std::fmt::{self, Display, Write};
pub mod breadcrumbs;
pub mod djot;
pub mod highlight;
pub mod navmap;
pub mod tree;
pub struct EscapeAttribute<'a>(pub &'a str);
impl Display for EscapeAttribute<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for c in self.0.chars() {
if c == '"' {
f.write_str("&quot;")?;
} else {
f.write_char(c)?;
}
}
Ok(())
}
}
pub struct EscapeHtml<'a>(pub &'a str);
impl Display for EscapeHtml<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for c in self.0.chars() {
match c {
'<' => f.write_str("&lt;")?,
'>' => f.write_str("&gt;")?,
'&' => f.write_str("&amp;")?,
'\'' => f.write_str("&apos;")?,
'"' => f.write_str("&quot;")?,
_ => f.write_char(c)?,
}
}
Ok(())
}
}