diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-06-13 06:40:48 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-06-13 06:40:48 +0200 |
commit | 07c2924e7abc9641df6f6bc6181c912b70904972 (patch) | |
tree | c006b1f66588c1b4e6f1a96c7d6be24c1a2d87a4 /src/new/section.rs | |
parent | feat(cli): Switch to stderrlog, configured by cli options (diff) | |
download | lpm-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 'src/new/section.rs')
-rw-r--r-- | src/new/section.rs | 11 |
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); |