From b190726a783a4aae98fad6b8fcfb266cabc4eb79 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Wed, 8 Jan 2025 12:26:03 +1300 Subject: More robust file traversal logic File traversal can now cope with symbolic links. The original path to each file is preserved where before they were unintentionally canonicalized, so the source folder prefix can now be correctly stripped from the path of each source file. This commit also adds the !folder syntax from the original toaster. Directories with a !-prefix are copied without modification to the site root. A --delete option has been added to the program. When this option is set, the destination directory is first deleted if it already exists. --- src/generate_html.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/generate_html.rs') diff --git a/src/generate_html.rs b/src/generate_html.rs index f14d5f9..05456d0 100644 --- a/src/generate_html.rs +++ b/src/generate_html.rs @@ -3,7 +3,7 @@ use crate::*; use markdown::*; -pub fn generate_html(document: &MarkdownDocument, page: &SourceFile, website: &Website) -> String { +pub fn generate_html(document: &MarkdownDocument, page: &Page, website: &Website) -> String { format!("\ @@ -27,7 +27,7 @@ pub fn generate_html(document: &MarkdownDocument, page: &SourceFile, website: &W -pub fn get_html_head(document: &MarkdownDocument, page: &SourceFile) -> String { +pub fn get_html_head(document: &MarkdownDocument, page: &Page) -> String { if let Some(Block::Fragment { language, content }) = document.blocks.first() { if language == "embed-html-head" { return content.to_string(); @@ -43,7 +43,7 @@ pub fn get_html_head(document: &MarkdownDocument, page: &SourceFile) -> String { -pub fn document_to_html(document: &MarkdownDocument, page: &SourceFile, website: &Website) -> String { +pub fn document_to_html(document: &MarkdownDocument, page: &Page, website: &Website) -> String { let mut html = String::new(); macro_rules! line_to_html { @@ -158,7 +158,7 @@ pub fn document_to_html(document: &MarkdownDocument, page: &SourceFile, website: -fn line_to_html(line: &Line, page: &SourceFile, website: &Website) -> String { +fn line_to_html(line: &Line, page: &Page, website: &Website) -> String { let mut html = String::new(); for line_element in &line.tokens { match line_element { -- cgit v1.2.3-70-g09d2