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(""")?; } 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("<")?, '>' => f.write_str(">")?, '&' => f.write_str("&")?, '\'' => f.write_str("'")?, '"' => f.write_str(""")?, _ => f.write_char(c)?, } } Ok(()) } }