diff --git a/src/viewer/html.rs b/src/viewer/html.rs new file mode 100644 index 0000000..9ba1007 --- /dev/null +++ b/src/viewer/html.rs @@ -0,0 +1,28 @@ +//! HTML 檢視器 + +use anyhow::Result; + +pub struct HtmlViewer { + content: Option, +} + +impl HtmlViewer { + pub fn new() -> Self { + Self { content: None } + } + + pub fn load_file(&mut self, path: &str) -> Result { + let content = std::fs::read_to_string(path)?; + self.content = Some(content.clone()); + Ok(content) + } + + pub fn load_content(&mut self, html: &str) -> String { + self.content = Some(html.to_string()); + html.to_string() + } + + pub fn get_content(&self) -> Option<&str> { + self.content.as_deref() + } +}