diff options
author | Qrius <[email protected]> | 2024-09-26 00:11:05 +0200 |
---|---|---|
committer | Qrius <[email protected]> | 2024-09-26 00:11:05 +0200 |
commit | eb2a8c1ac8db20d176b1af6a2ea26a5b27b996d9 (patch) | |
tree | d0ac51bb7dc4568d3a06afaa721a3e5b56b503b4 /src/macro_processor/macro_processor.rs | |
parent | fce39a1c9a44d4a7eb2234f5d15b86d1c3177ffa (diff) | |
download | skaldpress-eb2a8c1ac8db20d176b1af6a2ea26a5b27b996d9.tar.gz skaldpress-eb2a8c1ac8db20d176b1af6a2ea26a5b27b996d9.zip |
Add function for including a file, without doing any macro processing on it
Diffstat (limited to 'src/macro_processor/macro_processor.rs')
-rw-r--r-- | src/macro_processor/macro_processor.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/macro_processor/macro_processor.rs b/src/macro_processor/macro_processor.rs index 68347d0..3164aa6 100644 --- a/src/macro_processor/macro_processor.rs +++ b/src/macro_processor/macro_processor.rs @@ -152,6 +152,19 @@ fn smp_builtin_include( return smp.process_input(&input_file); } +/// Include a new file verbatum, don't do ANY additional processing +fn smp_builtin_include_verbatum( + smp: &mut MacroProcessor, + macro_name: &str, + args: &mut [String], +) -> Result<String, SMPError> { + if args.len() < 1 { + return Ok(macro_name.to_string()); + } + let arg0 = smp.process_input(&args[0])?; + fs::read_to_string(&arg0).map_err(|e| SMPError::IncludeError(2, e, arg0)) +} + /// Simply execute argument as shell command fn smp_builtin_shell( smp: &mut MacroProcessor, @@ -258,6 +271,10 @@ impl MacroProcessor { MacroType::Function(smp_builtin_include), ); self.define_macro( + String::from("include_verbatum"), + MacroType::Function(smp_builtin_include_verbatum), + ); + self.define_macro( String::from("shell"), MacroType::Function(smp_builtin_shell), ); |