Merge branch 'main' into syntect

This commit is contained in:
Grace Yoder 2025-07-07 12:44:51 -06:00 committed by GitHub
commit 262a2e23d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 115 additions and 15 deletions

View file

@ -1,10 +1,9 @@
use crate::helpers::read_doc_from_file;
use super::render::{execute_lua, expand_template, process_markdown, process_syntax_highlighting};
use anyhow::Result;
use kuchikiki::traits::TendrilSink;
use std::{
fs::read_to_string,
path::{Path, PathBuf},
};
use std::path::{Path, PathBuf}
;
pub fn serve_content(request_uri: &str) -> Result<String> {
// TODO: read from config
@ -12,8 +11,9 @@ pub fn serve_content(request_uri: &str) -> Result<String> {
let components = PathBuf::from("/var/www/htmlua/components");
let safe_path = Path::new(request_uri).strip_prefix("/")?;
let page_path = pages.join(safe_path);
let page_string = read_to_string(&page_path)?;
let doc = kuchikiki::parse_html().one(page_string);
let doc = read_doc_from_file(page_path)?;
let full_doc = expand_template(doc, &components, None)?;
let markdown_doc = process_markdown(full_doc)?;
let highlighted_doc = process_syntax_highlighting(markdown_doc)?;