diff --git a/src/lib.rs b/src/lib.rs
index df6a711..8e25e75 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -105,9 +105,14 @@ impl Historian {
if entry_metadata.is_file() && !child.ends_with(MD_EXTENSION) {
attachments.push(child);
} else if !(child.starts_with(".") || child == self.index_filename || child == DEFAULT_TOML_FILENAME) {
+ let mut full_name = format!("{}/{}", name, child);
+ if full_name.starts_with('/') {
+ full_name.remove(0);
+ }
+
children.push(Child {
name: child.to_owned(),
- full_name: format!("{}/{}", name, child),
+ full_name: full_name,
title: if entry_metadata.is_file() {
entry_path.file_stem().unwrap().to_str().unwrap().to_owned()
} else {
@@ -543,11 +548,12 @@ fn export_resource(resource_path: PathBuf, output_path: &str) {
let mut resource_output_path: PathBuf = output_path.into();
let resource_name = resource_path.file_name().unwrap().to_str().unwrap();
resource_output_path.push(&resource_name);
- println!("export resource {} to {:?}", resource_name, resource_output_path);
+ println!("export resource {} from {:?} to {:?}", resource_name, resource_path, resource_output_path);
fs::copy(resource_path, resource_output_path).unwrap();
}
fn export_wiki_page(historian: &Historian, renderer: &PageRenderer, name: &str, output_path: &str) {
+ println!("resolve page {} {:?}", name, historian.resolve_to_page(name).is_some());
if let Some(page) = historian.resolve_to_page(name) {
let page_path: PathBuf = page.full_name.to_owned().replace(".md", ".html").into();
let mut page_output_path: PathBuf = output_path.into();
@@ -570,12 +576,13 @@ fn export_wiki_page(historian: &Historian, renderer: &PageRenderer, name: &str,
page_html_file.write_all(page_html.as_bytes());
for attachment in page.attachments {
- let attachment_path = page_path.join(attachment);
+ let attachment_path = page.path.parent().unwrap().join(attachment);
export_resource(attachment_path, page_output_path.to_str().unwrap());
}
for child in page.children {
- export_wiki_page(historian, renderer, child.path.to_str().unwrap(), output_path);
+ println!("child {} {} {:?} {:?}", child.full_name, child.name, child.path, output_path);
+ export_wiki_page(historian, renderer, &child.full_name, output_path);
}
}
}
@@ -589,7 +596,7 @@ impl<'a> Linker<'a> {
pub fn new(historian: &Historian) -> Linker {
Linker {
historian,
- link_regex: Regex::new(r"\[\[(?[\w\s]+)(?:\|(?