summaryrefslogtreecommitdiff
path: root/src/doc.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-02-12 11:44:39 +0200
committerLars Wirzenius <liw@liw.fi>2023-02-12 11:44:39 +0200
commitf596cc56fc7174b6f0b7ccd27041c724e33ac3b2 (patch)
tree2b3c3e1f460b5871f76007cfb94ecf8003cd7cb1 /src/doc.rs
parent56ecd912aa8a2aebd51d2022166ed4940a7a738b (diff)
downloadsubplot-f596cc56fc7174b6f0b7ccd27041c724e33ac3b2.tar.gz
refactor: drop Document::markdowns field
The same information is in the metadata, so use that instead. Sponsored-by: author
Diffstat (limited to 'src/doc.rs')
-rw-r--r--src/doc.rs21
1 files changed, 3 insertions, 18 deletions
diff --git a/src/doc.rs b/src/doc.rs
index faa3a84..349e1f3 100644
--- a/src/doc.rs
+++ b/src/doc.rs
@@ -64,7 +64,6 @@ static KNOWN_PANDOC_CLASSES: &[&str] = &["numberLines", "noNumberLines"];
#[derive(Debug)]
pub struct Document {
subplot: PathBuf,
- markdowns: Vec<PathBuf>,
md: Markdown,
meta: Metadata,
files: EmbeddedFiles,
@@ -75,7 +74,6 @@ pub struct Document {
impl Document {
fn new(
subplot: PathBuf,
- markdowns: Vec<PathBuf>,
md: Markdown,
meta: Metadata,
files: EmbeddedFiles,
@@ -83,7 +81,6 @@ impl Document {
) -> Document {
let doc = Document {
subplot,
- markdowns,
md,
meta,
files,
@@ -102,7 +99,6 @@ impl Document {
fn from_ast<P>(
basedir: P,
subplot: PathBuf,
- markdowns: Vec<PathBuf>,
yamlmeta: &YamlMetadata,
md: Markdown,
style: Style,
@@ -119,7 +115,7 @@ impl Document {
return Err(issues.remove(0));
}
let files = md.embedded_files();
- let doc = Document::new(subplot, markdowns, md, meta, files, style);
+ let doc = Document::new(subplot, md, meta, files, style);
trace!("Loaded from JSON OK");
Ok(doc)
}
@@ -148,17 +144,8 @@ impl Document {
let mdfile = basedir.join(mdfile);
let mut md = Markdown::load_file(mdfile.as_path())?;
md.set_metadata(&meta);
- let markdowns = vec![mdfile];
- let doc = Self::from_ast(
- basedir,
- filename.into(),
- markdowns,
- &meta,
- md,
- style,
- template,
- )?;
+ let doc = Self::from_ast(basedir, filename.into(), &meta, md, style, template)?;
trace!("Loaded document OK");
Ok(doc)
@@ -208,9 +195,7 @@ impl Document {
names.push(PathBuf::from(x))
}
- for x in self.markdowns.iter() {
- names.push(x.to_path_buf());
- }
+ names.push(self.meta().markdown_filename().to_path_buf());
let mut images = self.md.images();
names.append(&mut images);