summary refs log tree commit diff stats
path: root/src/new/section.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-06-13 06:40:48 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-06-13 06:40:48 +0200
commit07c2924e7abc9641df6f6bc6181c912b70904972 (patch)
treec006b1f66588c1b4e6f1a96c7d6be24c1a2d87a4 /src/new/section.rs
parentfeat(cli): Switch to stderrlog, configured by cli options (diff)
downloadlpm-07c2924e7abc9641df6f6bc6181c912b70904972.tar.gz
lpm-07c2924e7abc9641df6f6bc6181c912b70904972.zip
feat(new): Ensure that file names are ASCII only
This allows us to just query the last chapter instead of storing it.
Diffstat (limited to '')
-rw-r--r--src/new/section.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/new/section.rs b/src/new/section.rs
index a359fb0..86d347c 100644
--- a/src/new/section.rs
+++ b/src/new/section.rs
@@ -1,4 +1,8 @@
-use std::{fs, path::Path, time::SystemTime};
+use std::{
+    fs,
+    path::Path,
+    time::{SystemTime, UNIX_EPOCH},
+};
 
 use anyhow::Context;
 use chrono::{DateTime, Local};
@@ -8,6 +12,7 @@ use log::debug;
 use crate::{
     config_file::Config,
     file_tree::{FileTree, GeneratedFile},
+    new::MangledName,
 };
 
 pub fn generate_new_section(
@@ -37,7 +42,7 @@ pub fn generate_new_section(
     let new_section_file = GeneratedFile::new(
         chapter_root
             .join("sections")
-            .join(format!("{}.tex", name.to_case(Case::Snake))),
+            .join(format!("{}.tex", MangledName::new(&name))),
         new_section_text,
     );
     file_tree.add_file(new_section_file);
@@ -53,7 +58,7 @@ pub fn generate_new_section(
     chapter_file_text.push_str(&format!(
         "\\input{{content/{}/sections/{}}}\n",
         chapter_name,
-        &name.to_case(Case::Snake)
+        &MangledName::new(&name)
     ));
 
     let chapter_file = GeneratedFile::new(chapter_file_path, chapter_file_text);