From 4acc0dc21f39b9eff6f5e8fc510f3dfe5459d900 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 15 May 2022 13:20:57 +0100 Subject: [PATCH] magic: Use new ${image} syntax Signed-off-by: Ian Jackson --- library/edited.toml | 2 +- src/shapelib.rs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/library/edited.toml b/library/edited.toml index cfd6eefb..7d1b12d7 100644 --- a/library/edited.toml +++ b/library/edited.toml @@ -36,7 +36,7 @@ d6-_c - a ${colour} die image magic.item_prefix = "die-" magic.template = """ -image = ! +image = ${image} type = "Die" labels = 6 desc = "a ${colour} die" diff --git a/src/shapelib.rs b/src/shapelib.rs index 766ecb89..3e2d318e 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -1405,11 +1405,9 @@ fn process_files_entry( let item_name = subst_item_name(&format_item_name( mformat, &magic.item_prefix, &fe, &magic.item_suffix)?)?; - let spec = regex!(r#"(?m)(^[\sA-Za-z0-9._-]+=\s*)!\s*$"#) - .replace_all(&magic.template, |caps: ®ex::Captures| { - format!("{}{}", caps.get(1).unwrap().as_str(), &image_table) - }); - let spec = c_colour_all((*spec).into())?; + let spec = Substituting::new(mformat, Dollars::Text, &magic.template); + let spec = substn(spec, "_image", &image_table)?; + let spec = c_colour_all(spec.into())?; let spec = spec.finish()?; trace!("magic item {}\n\n{}\n", &item_name, &spec); -- 2.30.2