diff options
-rw-r--r-- | src/doc.rs | 29 |
1 files changed, 10 insertions, 19 deletions
@@ -135,22 +135,6 @@ impl Document { Ok(doc) } - /// Construct a Document from a JSON AST - pub fn from_json<P>( - basedir: P, - markdowns: Vec<PathBuf>, - json: &str, - style: Style, - template: Option<&str>, - ) -> Result<Document, SubplotError> - where - P: AsRef<Path> + Debug, - { - trace!("Parsing document..."); - let ast: Pandoc = serde_json::from_str(json).map_err(SubplotError::AstJson)?; - Self::from_ast(basedir, markdowns, ast, style, template) - } - /// Construct a Document from a named file. /// /// The file can be in any format Pandoc understands. This runs @@ -181,13 +165,20 @@ impl Document { // Add external Pandoc filters. crate::policy::add_citeproc(&mut pandoc); - trace!("Invoking Pandoc to parse document {:?}", filename); - let output = match pandoc.execute().map_err(SubplotError::Pandoc)? { + trace!( + "Invoking Pandoc to parse document {:?} into AST as JSON", + filename + ); + let json = match pandoc.execute().map_err(SubplotError::Pandoc)? { pandoc::PandocOutput::ToBuffer(o) => o, _ => return Err(SubplotError::NotJson), }; trace!("Pandoc was happy"); - let doc = Document::from_json(basedir, markdowns, &output, style, template)?; + + trace!("Parsing document AST as JSON..."); + let ast: Pandoc = serde_json::from_str(&json).map_err(SubplotError::AstJson)?; + let doc = Self::from_ast(basedir, markdowns, ast, style, template)?; + trace!("Loaded document OK"); Ok(doc) } |