remove treehouse-format crate and collapse everything into src
This commit is contained in:
parent
ca127a9411
commit
b792688776
66 changed files with 145 additions and 112 deletions
40
src/html.rs
Normal file
40
src/html.rs
Normal 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(""")?;
|
||||
} 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(())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue