2023-08-20 12:15:48 +02:00
|
|
|
use std::fmt::{self, Display, Write};
|
|
|
|
|
2023-08-28 21:14:51 +02:00
|
|
|
pub mod breadcrumbs;
|
2024-11-27 19:02:30 +01:00
|
|
|
pub mod djot;
|
2024-03-10 23:23:50 +01:00
|
|
|
pub mod highlight;
|
2023-08-27 14:50:46 +02:00
|
|
|
pub mod navmap;
|
2023-08-18 17:04:12 +02:00
|
|
|
pub mod tree;
|
2023-08-20 12:15:48 +02:00
|
|
|
|
2024-11-16 18:33:41 +01:00
|
|
|
pub struct EscapeAttribute<'a>(pub &'a str);
|
2023-08-20 12:15:48 +02:00
|
|
|
|
2024-11-16 18:33:41 +01:00
|
|
|
impl Display for EscapeAttribute<'_> {
|
2023-08-20 12:15:48 +02:00
|
|
|
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(())
|
|
|
|
}
|
|
|
|
}
|
2023-08-20 15:05:59 +02:00
|
|
|
|
2024-11-16 18:33:41 +01:00
|
|
|
pub struct EscapeHtml<'a>(pub &'a str);
|
2023-08-20 15:05:59 +02:00
|
|
|
|
2024-11-16 18:33:41 +01:00
|
|
|
impl Display for EscapeHtml<'_> {
|
2023-08-20 15:05:59 +02:00
|
|
|
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(())
|
|
|
|
}
|
|
|
|
}
|