Skip to content

Commit

Permalink
provide full bib output file path to citation templates
Browse files Browse the repository at this point in the history
  • Loading branch information
mlange-42 authored and francisco-perez-sorrosal committed Jan 20, 2023
1 parent b840189 commit 5e41262
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod config;
mod file_utils;

static NAME: &str = "bib";
static BIB_OUT_FILE: &str = "bibliography";

pub struct Bibiography;

Expand Down Expand Up @@ -174,7 +175,7 @@ impl Bibiography {
Chapter::new(
&title,
format!("# {title}\n{html_content}"),
PathBuf::from("bibliography.md"),
PathBuf::from(format!("{BIB_OUT_FILE}.md")),
Vec::new(),
)
}
Expand Down Expand Up @@ -562,7 +563,7 @@ impl<'a> Placeholder<'a> {
}
let citation = Citation {
item: item.to_owned(),
path: path_to_root,
path: format!("{path_to_root}{BIB_OUT_FILE}.html"),
};
handlebars
.render("citation", &citation)
Expand Down
2 changes: 1 addition & 1 deletion src/render/cite_key.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[[{{item.citation_key}}]({{path}}bibliography.html#{{item.citation_key}})]
[[{{item.citation_key}}]({{path}}#{{item.citation_key}})]
2 changes: 1 addition & 1 deletion templates/cite_author_year.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{{item.authors.[0].[0]}}{{#if item.authors.[2]}} et al.{{else}}{{#if item.authors.[1]}} & {{item.authors.[1].[0]}}{{/if}}{{/if}} {{item.pub_year}}]({{path}}bibliography.html#{{item.citation_key}})
[{{item.authors.[0].[0]}}{{#if item.authors.[2]}} et al.{{else}}{{#if item.authors.[1]}} & {{item.authors.[1].[0]}}{{/if}}{{/if}} {{item.pub_year}}]({{path}}#{{item.citation_key}})
2 changes: 1 addition & 1 deletion templates/cite_index.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{{item.index}}]({{path}}bibliography.html#{{item.citation_key}})
[{{item.index}}]({{path}}#{{item.citation_key}})
2 changes: 1 addition & 1 deletion templates/cite_key.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[[{{item.citation_key}}]({{path}}bibliography.html#{{item.citation_key}})]
[[{{item.citation_key}}]({{path}}#{{item.citation_key}})]

0 comments on commit 5e41262

Please sign in to comment.