diff --git a/src/main.rs b/src/main.rs
@@ -1,11 +1,15 @@
use std::env;
+use std::fmt::{self, Display};
use std::fs::{self, File};
use std::io::{self, Write};
use std::path::PathBuf;
use std::process::exit;
-use types::{Escaped, Picture};
+use picture::Picture;
-mod types;
+mod picture;
+
+/// A wrapper for HTML-escaped strings
+pub struct Escaped<'a>(pub &'a str);
const TARGET_PATH: &str = "./site";
const PAGES_PATH: &str = "photos";
@@ -287,3 +291,20 @@ fn usage_config() {
eprintln!(" alt: \"Text alternative for the second photo\"");
eprintln!(" ...");
}
+
+impl<'a> Display for Escaped<'a> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
+ for c in self.0.chars() {
+ match c {
+ '<' => write!(f, "<")?,
+ '>' => write!(f, ">")?,
+ '&' => write!(f, "&")?,
+ '"' => write!(f, """)?,
+ '\'' => write!(f, "'")?,
+ c => c.fmt(f)?,
+ }
+ }
+
+ Ok(())
+ }
+}