Add html.rs viewer

This commit is contained in:
2026-03-19 00:32:14 +08:00
parent 0a04b752fd
commit 4877b5f0a7

28
src/viewer/html.rs Normal file
View File

@@ -0,0 +1,28 @@
//! HTML 檢視器
use anyhow::Result;
pub struct HtmlViewer {
content: Option<String>,
}
impl HtmlViewer {
pub fn new() -> Self {
Self { content: None }
}
pub fn load_file(&mut self, path: &str) -> Result<String> {
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()
}
}