summaryrefslogtreecommitdiff
path: root/src/generate_html.rs
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2025-01-08 12:26:03 +1300
committerBen Bridle <bridle.benjamin@gmail.com>2025-01-08 12:26:31 +1300
commitb190726a783a4aae98fad6b8fcfb266cabc4eb79 (patch)
treed8c9fb60e9792c562f60f489a659a4004593b672 /src/generate_html.rs
parentaf2507508f7877eace40b119c2a6fab1aefc6bc2 (diff)
downloadtoaster-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.rs8
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 {