Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert a "XXXX et al." citation. #133

Open
Klemet opened this issue Dec 20, 2021 · 8 comments
Open

Insert a "XXXX et al." citation. #133

Klemet opened this issue Dec 20, 2021 · 8 comments
Milestone

Comments

@Klemet
Copy link

Klemet commented Dec 20, 2021

Before everything, thank you so much for this wonderful plugin ! It's a joy to use !

What is proposed

To make it even more flexible, I'd love to be able to add a proper XXXX *et al.*, YYYY citation type in Markdown format. This is in the particular case of wanting your markdown notes to be properly formatted without being parsed by pandoc.

In Markdown, this would look like:

As it is said by [Test *et al.*, 2018](link/to/paper), blablabla

Rendered, it would look like:

As it is said by Test et al., 2018, blablabla

As of today, the plugin is already almost capable of doing this, using an extremely convoluted handlebars sentence:

[{{#each entry.author}}{{#if @first}}{{#if this.family}}{{this.family}}{{#unless @last}} *et al.*{{/unless}}{{else}}{{../authorString}}{{/if}}{{/if}}{{/each}}, {{#if year}}{{year}}{{else}}no date{{/if}}]({{zoteroSelectURI}})

What the sentence does is to:

  1. Display the family name of the first author (if it has one)
  2. Add "et al." next to it if this first author if it is not the last author of the list of authors (if not, write nothing since there's no other authors)
  3. If the author has no family name or given name (which happens when it's an organization with only one name), I can't get the name of the author via this.given or this.family; so, the sentence writes the authorString in full (not ideal)
  4. If there is a year, add it.
  5. As a link, add the zotero select URI (my personal preference; can be replaced by the DOI URL via https://doi.org/{{DOI}} or other URL)

It works pretty well, but it seems a bit complex for most users. It took me a lot of time myself 😄 !

What is needed

Ideally, I imagine that allowing the use of a csl file to custom the appearance of this citation would be ideal; but it would require a lot of work.

Using this type of long handlebar syntax could be good, but needs to be explained to the users properly; maybe this example could be given ?

If it is given, it could be nice to think of a way to replace the authorString in case the name of the author cannot be gathered via this.given or this.family. If you have a pointer for that, I'd be much obliged.


Thanks again for your work !

@geblanco
Copy link

geblanco commented Jan 4, 2022

This sounds really good, after wandering around I've come to your solution and as non-TS guy, it saved my day, thanks @Klemet!

@baileymh
Copy link

baileymh commented Feb 6, 2022

I'm not super familiar with handlebars, would it be possible to tweak your sentence to add et al. if there are more than two authors, rather than more than one?

So:
Brand and Hoth, 2017 instead of Brand et al., 2017
But still Brand et al., 2017 for Brand, Hoth, and Smith, 2017`?

@Klemet
Copy link
Author

Klemet commented Feb 6, 2022

I wanted to do that, @baileymh ; however, I couldn't find a term in the handlebar syntax that gave the number of authors in the list of authors.

The only thing that I could test for was to see if the first author is also the last of the list; if that's the case, that means that there's only one author. If not, the sentence adds "et al.".

@baileymh
Copy link

baileymh commented Feb 6, 2022

Gotcha. I tried looking through a bit but couldn't see anything, wasn't sure if there was just more that I didn't know about.

Either way, thanks a lot for the work above, gets me most of the way to what I want, much appreciated!

@mapfiable
Copy link

mapfiable commented Apr 12, 2022

EDIT I had a few misconceptions, so I updated the post.

I was trying to use this for the note creation template, however in a slightly changed form, so that articles that came out in the same year have the year appended by a letter, as is the case in zotero. I don't speak Handlebars however.

{{#each entry.author}}{{#if @first}}{{#if this.family}}{{this.family}}{{#unless @last}} et al.{{/unless}}{{else}}{{../authorString}}{{/if}}{{/if}}{{/each}} ({{#if year}}{{year}}{{#if isNaN (Number entry.id.[entry.id.length - 1])}}{{entry.id.[entry.id.length - 1]}}{{/if}}{{else}}no date{{/if}})

I wanted to base the syntax on these two posts: one, two. However, I guess I would need to use helpers for that, but I don't know how. It already doesn't work if I just try to print entry.id.length - 1.

@hans
Copy link
Owner

hans commented May 14, 2022

Hi all, I'm impressed by your Handlebars solutions here!
CSL-driven automatic rendering of inline citations will be coming in the next major release. Stay tuned!

@hans hans added this to the 0.5.0 milestone May 14, 2022
@hans
Copy link
Owner

hans commented May 14, 2022

See also more creative JS solutions in #53 .

@mapfiable
Copy link

@hans

Hi all, I'm impressed by your Handlebars solutions here! CSL-driven automatic rendering of inline citations will be coming in the next major release. Stay tuned!

Hi @hans, is the new major update of the citation plugin still in the works? I would really love for this functionality to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants