extern crate pandoc;
fn main() {
let mut p = pandoc::Pandoc::new();
p.add_input("test.mediawiki");
p.set_output_format(pandoc::OutputFormat::Json);
p.set_input_format(pandoc::InputFormat::MediaWiki);
p.set_output(pandoc::OutputKind::File("output.txt".into()));
match p.execute() {
Ok(_) => println!("It worked."),
Err(e) => println!("Error: {:?}", e),
}
}
When the specified input file is missing, the output looks like this:
pandoc: test.mediawiki: openFile: does not exist (No such file or directory)
Error: exit_code: Some(1)stdout: stderr:
As shown, Pandoc prints its stderr itself and the members of the error object do
not contain the desired output. For a broken document with a syntax error, this
would look like this:
pandoc:
Error at "source" (line 75, column 1):
unexpected end of input
expecting "|", "!", "||", "!!", "|-", lf new-line or "|}"
^
CallStack (from HasCallStack):
error, called at src/Text/Pandoc/Error.hs:66:13 in pandoc-1.17.2-Cq2iGUE9cDsAnk3CjbY7fx:Text.Pandoc.Error
Error: exit_code: Some(1)stdout: stderr:
It would be great if stderr could be properly captured, so that Pandoc can be
used as a silent back-end. It would also allow for post-processing of the error
message.
Consider the following code:
When the specified input file is missing, the output looks like this:
As shown, Pandoc prints its stderr itself and the members of the error object do not contain the desired output. For a broken document with a syntax error, this would look like this:
It would be great if stderr could be properly captured, so that Pandoc can be used as a silent back-end. It would also allow for post-processing of the error message.
Thanks