summaryrefslogtreecommitdiff
path: root/src/typeset.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-04-02 12:45:18 +0300
committerLars Wirzenius <liw@liw.fi>2022-04-10 15:57:57 +0300
commit7db158701e781175ead38ca1e63f6115ce527cef (patch)
treee9757b730b34038b70a0f6ea60cadc0a6764f920 /src/typeset.rs
parentc9627df005b5344f437c9eaaa98bb5fe00c47313 (diff)
downloadsubplot-7db158701e781175ead38ca1e63f6115ce527cef.tar.gz
feat: report markup problems during typesetting as a warning
Sponsored-by: author
Diffstat (limited to 'src/typeset.rs')
-rw-r--r--src/typeset.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/typeset.rs b/src/typeset.rs
index 49b8aed..bc86ef8 100644
--- a/src/typeset.rs
+++ b/src/typeset.rs
@@ -154,11 +154,11 @@ pub fn link_as_note(attr: Attr, text: Vec<Inline>, target: Target) -> Inline {
///
/// If the code block which contained the pikchr contains other classes, they
/// can be added to the SVG for use in later typesetting etc.
-pub fn pikchr_to_block(pikchr: &str, class: Option<&str>) -> Block {
+pub fn pikchr_to_block(pikchr: &str, class: Option<&str>, warnings: &mut Warnings) -> Block {
match PikchrMarkup::new(pikchr, class).as_svg() {
Ok(svg) => typeset_svg(svg),
Err(err) => {
- eprintln!("pikchr render failed: {}", err);
+ warnings.push(Warning::Pikchr(format!("{}", err)));
error(err)
}
}
@@ -167,11 +167,11 @@ pub fn pikchr_to_block(pikchr: &str, class: Option<&str>) -> Block {
// Take a dot graph, render it as SVG, and return an AST Block
// element. The Block will contain the SVG data. This allows the graph
// to be rendered without referending external entities.
-pub fn dot_to_block(dot: &str) -> Block {
+pub fn dot_to_block(dot: &str, warnings: &mut Warnings) -> Block {
match DotMarkup::new(dot).as_svg() {
Ok(svg) => typeset_svg(svg),
Err(err) => {
- eprintln!("dot failed: {}", err);
+ warnings.push(Warning::Dot(format!("{}", err)));
error(err)
}
}
@@ -180,11 +180,11 @@ pub fn dot_to_block(dot: &str) -> Block {
// Take a PlantUML graph, render it as SVG, and return an AST Block
// element. The Block will contain the SVG data. This allows the graph
// to be rendered without referending external entities.
-pub fn plantuml_to_block(markup: &str) -> Block {
+pub fn plantuml_to_block(markup: &str, warnings: &mut Warnings) -> Block {
match PlantumlMarkup::new(markup).as_svg() {
Ok(svg) => typeset_svg(svg),
Err(err) => {
- eprintln!("plantuml failed: {}", err);
+ warnings.push(Warning::Plantuml(format!("{}", err)));
error(err)
}
}
@@ -192,13 +192,13 @@ pub fn plantuml_to_block(markup: &str) -> Block {
/// Typeset a project roadmap expressed as textual YAML, and render it
/// as an SVG image.
-pub fn roadmap_to_block(yaml: &str) -> Block {
+pub fn roadmap_to_block(yaml: &str, warnings: &mut Warnings) -> Block {
match roadmap::from_yaml(yaml) {
Ok(ref mut roadmap) => {
roadmap.set_missing_statuses();
let width = 50;
match roadmap.format_as_dot(width) {
- Ok(dot) => dot_to_block(&dot),
+ Ok(dot) => dot_to_block(&dot, warnings),
Err(e) => Block::Para(vec![inlinestr(&e.to_string())]),
}
}