diff options
author | Ben Bridle <bridle.benjamin@gmail.com> | 2025-01-08 12:26:03 +1300 |
---|---|---|
committer | Ben Bridle <bridle.benjamin@gmail.com> | 2025-01-08 12:26:31 +1300 |
commit | b190726a783a4aae98fad6b8fcfb266cabc4eb79 (patch) | |
tree | d8c9fb60e9792c562f60f489a659a4004593b672 /src/generate_html.rs | |
parent | af2507508f7877eace40b119c2a6fab1aefc6bc2 (diff) | |
download | toaster-b190726a783a4aae98fad6b8fcfb266cabc4eb79.zip |
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.
Diffstat (limited to 'src/generate_html.rs')
-rw-r--r-- | src/generate_html.rs | 8 |
1 files changed, 4 insertions, 4 deletions
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!("\ <!DOCTYPE html> <head> @@ -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 { |