diff options
| author | gyoder <70408179+gyoder@users.noreply.github.com> | 2025-07-21 12:35:51 -0600 |
|---|---|---|
| committer | gyoder <70408179+gyoder@users.noreply.github.com> | 2025-07-21 12:35:51 -0600 |
| commit | bfa5d30ae4cd56804093fefd0d91f5f18116d0bc (patch) | |
| tree | ee15f48ebb7e4ae987dfa5d7528b057b100d782e /htmlua-parser/src/serve.rs | |
| parent | a07d893e6e137cc3641312e95b191a018c8643db (diff) | |
fixed parser bugrustrender_fixes
Diffstat (limited to 'htmlua-parser/src/serve.rs')
| -rw-r--r-- | htmlua-parser/src/serve.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/htmlua-parser/src/serve.rs b/htmlua-parser/src/serve.rs index 715bfcc..375e885 100644 --- a/htmlua-parser/src/serve.rs +++ b/htmlua-parser/src/serve.rs @@ -1,6 +1,6 @@ use std::{path::Path, sync::OnceLock}; -use anyhow::Result; +use anyhow::{Result, anyhow}; use crate::{ config::Config, @@ -13,7 +13,7 @@ static CONFIG: OnceLock<Config> = OnceLock::new(); pub fn get_config() -> &'static Config { CONFIG.get_or_init(|| { Config::load().unwrap_or_else(|e| { - eprintln!("Warning: Failed to load config: {}", e); + eprintln!("Warning: Failed to load config: {e}"); eprintln!("Using default configuration"); Config::default() }) @@ -24,8 +24,10 @@ pub fn serve_content(request_uri: &str) -> Result<String> { let config = get_config(); let safe_path = Path::new(request_uri).strip_prefix("/")?; let page_path = config.paths.pages.join(safe_path); - let doc = read_doc_from_file(page_path)?; - let full_doc = expand_template(doc, &config.paths.components, None)?; + let doc = read_doc_from_file(page_path)? + .select_first("html") + .map_err(|()| anyhow!("failed to read doc"))?; + let full_doc = expand_template(doc.as_node().to_owned(), &config.paths.components, None)?; let markdown_doc = process_markdown(full_doc)?; let highlighted_doc = process_syntax_highlighting(markdown_doc)?; let executed_doc = execute_lua(highlighted_doc)?; |
