summaryrefslogtreecommitdiff
path: root/src/doc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc.rs')
-rw-r--r--src/doc.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/doc.rs b/src/doc.rs
index 2ed3ef5..cc6a616 100644
--- a/src/doc.rs
+++ b/src/doc.rs
@@ -82,6 +82,7 @@ static KNOWN_PANDOC_CLASSES: &[&str] = &["numberLines", "noNumberLines"];
/// ~~~~
#[derive(Debug)]
pub struct Document {
+ subplot: PathBuf,
markdowns: Vec<PathBuf>,
ast: Pandoc,
meta: Metadata,
@@ -92,6 +93,7 @@ pub struct Document {
impl Document {
fn new(
+ subplot: PathBuf,
markdowns: Vec<PathBuf>,
ast: Pandoc,
meta: Metadata,
@@ -99,6 +101,7 @@ impl Document {
style: Style,
) -> Document {
Document {
+ subplot,
markdowns,
ast,
meta,
@@ -115,6 +118,7 @@ impl Document {
fn from_ast<P>(
basedir: P,
+ subplot: PathBuf,
markdowns: Vec<PathBuf>,
yamlmeta: &ast::YamlMetadata,
mut ast: Pandoc,
@@ -133,7 +137,7 @@ impl Document {
return Err(linter.issues.remove(0));
}
let files = EmbeddedFiles::new(&mut ast);
- let doc = Document::new(markdowns, ast, meta, files, style);
+ let doc = Document::new(subplot, markdowns, ast, meta, files, style);
trace!("Loaded from JSON OK");
Ok(doc)
}
@@ -186,7 +190,15 @@ impl Document {
trace!("Parsing document AST as JSON...");
let mut ast: Pandoc = serde_json::from_str(&json).map_err(SubplotError::AstJson)?;
ast.meta = meta.to_map();
- let doc = Self::from_ast(basedir, markdowns, &meta, ast, style, template)?;
+ let doc = Self::from_ast(
+ basedir,
+ filename.into(),
+ markdowns,
+ &meta,
+ ast,
+ style,
+ template,
+ )?;
trace!("Loaded document OK");
Ok(doc)
@@ -214,7 +226,8 @@ impl Document {
trace!("Parsed document OK");
Self::from_ast(
basedir,
- vec![filename.into()],
+ filename.into(),
+ vec![mdfile],
&meta,
ast.to_pandoc(),
style,
@@ -241,7 +254,7 @@ impl Document {
/// The sources are any files that affect the output so that if
/// the source file changes, the output needs to be re-generated.
pub fn sources(&mut self, template: Option<&str>) -> Vec<PathBuf> {
- let mut names = vec![];
+ let mut names = vec![self.subplot.clone()];
for x in self.meta().bindings_filenames() {
names.push(PathBuf::from(x))