diff options
Diffstat (limited to 'src/typeset.rs')
-rw-r--r-- | src/typeset.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/typeset.rs b/src/typeset.rs index c6301e4..49b8aed 100644 --- a/src/typeset.rs +++ b/src/typeset.rs @@ -5,6 +5,7 @@ use crate::ScenarioStep; use crate::StepKind; use crate::SubplotError; use crate::{DotMarkup, GraphMarkup, PikchrMarkup, PlantumlMarkup}; +use crate::{Warning, Warnings}; use pandoc_ast::Attr; use pandoc_ast::Block; @@ -53,13 +54,13 @@ pub fn file_block(attr: &Attr, text: &str) -> Block { /// /// The snippet is given as a text string, which is parsed. It need /// not be a complete scenario, but it should consist of complete steps. -pub fn scenario_snippet(bindings: &Bindings, snippet: &str) -> Block { +pub fn scenario_snippet(bindings: &Bindings, snippet: &str, warnings: &mut Warnings) -> Block { let lines = parse_scenario_snippet(snippet); let mut steps = vec![]; let mut prevkind: Option<StepKind> = None; for line in lines { - let (this, thiskind) = step(bindings, line, prevkind); + let (this, thiskind) = step(bindings, line, prevkind, warnings); steps.push(this); prevkind = thiskind; } @@ -71,6 +72,7 @@ fn step( bindings: &Bindings, text: &str, prevkind: Option<StepKind>, + warnings: &mut Warnings, ) -> (Vec<Inline>, Option<StepKind>) { let step = ScenarioStep::new_from_str(text, prevkind); if step.is_err() { @@ -84,11 +86,9 @@ fn step( let m = match bindings.find("", &step) { Ok(m) => m, Err(e) => { - eprintln!("Could not select binding: {:?}", e); - return ( - error_msg(&format!("Could not select binding for: {}", text)), - prevkind, - ); + let w = Warning::UnknownBinding(format!("{}", e)); + warnings.push(w.clone()); + return (error_msg(&format!("{}", w)), prevkind); } }; |