From 07c2924e7abc9641df6f6bc6181c912b70904972 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Thu, 13 Jun 2024 06:40:48 +0200 Subject: feat(new): Ensure that file names are ASCII only This allows us to just query the last chapter instead of storing it. --- src/new/section.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/new/section.rs') 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); -- cgit 1.4.1