diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-09-29 11:48:59 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-09-29 11:49:13 +0200 |
commit | 800ffaf658c3defe165dd24c3ecd65ceabc7096a (patch) | |
tree | b9b2e44ac8a73efecdba3ac65be4ebb0dd20e239 /src/new/figure.rs | |
parent | fix(MangledName): Also replace `"` and `'` (diff) | |
download | lpm-800ffaf658c3defe165dd24c3ecd65ceabc7096a.tar.gz lpm-800ffaf658c3defe165dd24c3ecd65ceabc7096a.zip |
feat(new/figure)!: Init
BREAKING CHANGE: The config file now needs to contain an `templates.figure` key. You can simply add this.
Diffstat (limited to 'src/new/figure.rs')
-rw-r--r-- | src/new/figure.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/new/figure.rs b/src/new/figure.rs new file mode 100644 index 0000000..3099f94 --- /dev/null +++ b/src/new/figure.rs @@ -0,0 +1,28 @@ +use std::path::Path; + +use crate::{ + config_file::Config, + file_tree::{FileTree, GeneratedFile}, +}; + +use super::{replacement::untemplatize_figure, MangledName}; + +pub fn generate_new_figure( + config: &Config, + name: String, + project_root: &Path, +) -> anyhow::Result<FileTree> { + let mut file_tree = FileTree::new(); + + let new_figure_text = untemplatize_figure(&config.templates.figure, &name); + + file_tree.add_file(GeneratedFile::new_clobber( + project_root + .join("figures") + .join(format!("{}.tex", MangledName::new(&name))), + new_figure_text, + false, + )); + + Ok(file_tree) +} |