From d0fe56f4e98fa552c5e271713a815d2382e614f7 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 29 Sep 2024 10:11:35 +0200 Subject: feat(templates): Provide a consistent syntax for replacements All replacements now start with `lpm::` and thus provide a future way to extend them. This change also adds the ability to access the chapter name in a new section and the current data in a new chapter. --- src/new/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/new/mod.rs') diff --git a/src/new/mod.rs b/src/new/mod.rs index 8d8193c..04b75ef 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -4,6 +4,7 @@ use convert_case::{Case, Casing}; use deunicode::deunicode; pub mod chapter; +pub mod replacement; pub mod section; #[derive(PartialEq, Eq, PartialOrd, Ord)] @@ -29,6 +30,10 @@ impl MangledName { pub fn as_str(&self) -> &str { &self.0 } + + pub fn try_unmangle(self) -> String { + self.0.to_case(Case::Title) + } } impl Display for MangledName { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { -- cgit 1.4.1