diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-09-03 11:51:02 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-09-03 11:51:02 +0300 |
commit | c4b98e69050a94cac865af4d5f92985b9e5262b3 (patch) | |
tree | 676130f43ff2270f2f2ef116cc927214a67983ad | |
parent | ac65d482c4bae8a98feb0d74e2cbe797b61c1d84 (diff) | |
download | subplot-c4b98e69050a94cac865af4d5f92985b9e5262b3.tar.gz |
refactor: drop unnecessary single-line function used from one caller
Sponsored-by: author
-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) } |