New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
A template to insert (Pandoc-style) rendered citation #53
Comments
I'm interested in what you mean, but I can't really get what you want to achieve. Could you maybe explain what you mean with "but cannot think of other templates for the other aliases"? Thanks! :) |
Hey @phlind, I mean, I am looking for a I can then make something like this in the header template: ---
aliases:
- {{title}}
- {{citeRenderPromary}}
- {citeRenderSecondary}}
---
to render this YAML: ---
aliases:
- Hidden Markov and other models for discrete-valued time series
- (MacDonald & Zucchini, 1997)
- MacDonald and Zucchini (1997)
--- |
You can do something like this with Templater :) This my template: ---
title: "{{title}}"
authors: "{{authorString}}"
year: {{year}}
zotero: "{{zoteroSelectURI}}"
publication: "{{containerTitle}}"
aliases:
- "<% `${tp.user.authorShort("{{authorString}}")}, ${"{{year}}"}` %>"
- "<% `${tp.user.authorShort("{{authorString}}")} (${"{{year}}"})` %>"
- "<% `${tp.user.authorLong("{{authorString}}")} (${"{{year}}"}). ${"{{title}}"}. ${"{{containerTitle}}"}.`%>"
---
function authorShort(authorString) {
const authors = authorString.split(", ");
let abbrAuthorString = ""
if (authors.length == 1) {
const parts = authors[0].split(" ")
abbrAuthorString = parts[parts.length-1];
}
else if (authors.length == 2) {
let surnames = [];
authors.forEach(author => {
const parts = author.split(" ");
surnames.push(parts[parts.length-1]);
})
abbrAuthorString = `${surnames[0]} and ${surnames[1]}`;
} else {
const first = authors[0].split(" ")
const surname = first[first.length - 1];
abbrAuthorString = `${surname} et al.`;
}
return abbrAuthorString
}
module.exports = authorShort; function authorLong(authorString) {
const authors = authorString.split(", ");
let fullAuthorList = [];
authors.forEach(author => {
const parts = author.split(" ");
let str = [];
str.push(parts[parts.length-1]);
const name_parts = parts.slice(0, parts.length-1);
name_parts.forEach(name => {
str.push(", ");
str.push(`${name[0]}.`);
});
fullAuthorList.push(str.join(""))
});
return fullAuthorList.join(", ")
}
module.exports = authorLong; I know this probably isn't perfect, but it's close enough to what you and I want :) |
I added the following (among other minor edits) into Object.defineProperty(Entry.prototype, "authorYear", {
get: function () {
if (this.data.creators.author.length == 1)
return this.data.creators.author[0].lastName + ', ' + this.data.fields.year
else if (this.data.creators.author.length == 2)
return this.data.creators.author[0].lastName + ' and ' + this.data.creators.author[1].lastName + ', ' + this.data.fields.year
else
return this.data.creators.author[0].lastName + ' et al., ' + this.data.fields.year
},
enumerable: false,
configurable: true
}); Although now I think cbr9's solution is neater. |
|
This pertains to #41 and #42, and I thought it's better to have an issue on its own (btw, I'd like to give #44 a push 馃槃 too):
I am using @{{citekey}} as note names, but I'd like to use aliases implemented from v0.9.16 unward. For instance, for the following
bibtex
entry:have aliases as follows:
{{title}}
makes the first line, but cannot think of other templates for the other aliases; something like[@{{citekey}}]
and@{{citekey}}
.Thanks in advance!
The text was updated successfully, but these errors were encountered: