Zotero-better-bibtex: Add Access Date and URL in Bibliography with Better BibTeX

Created on 20 Mar 2020  路  11Comments  路  Source: retorquere/zotero-better-bibtex

Hello there,

I am trying to add the access date and the URL of a "website" element of Zotero to my bibliography. I am using the code form this webpage*, which can be found under "Samples" and the headline: "Add accessdate, url for BibTeX". So far everything works fine except I would like to add some changes to the access date presented.

This is the code I am using so far (slightly modified to what I found on the website)

if (Translator.BetterBibTeX && item.itemType === 'webpage') {
    if (item.accessDate) {
      reference.add({ name: 'note', value: "Zuletzt gepr眉ft " + item.accessDate + " " });
    }
    if (item.url) {
      reference.add({ name: 'howpublished', bibtex: "{\\url{" + reference.enc_verbatim({value: item.url}) + "}}" });
    }
  }

This is what is shown in my bibliography:
Boltzmann-Statistik - Wikipedia. Https://de.wikipedia.org//wiki/Boltzmannn-Statistik, . - Zuletzt gepr眉ft 2020-03-12T12:27:30Z

Questions:

  • I would like to get rid of the comma and period and maybe even the dash in between the URL and the "Zuletzt gepr眉ft".
  • Also I would like to get rid of the "T12:27:30Z" in "2020-03-12T12:27:30Z".

  • Moreover I would like to change the order and style of the date displayed to: 12.03.2020

Is there any way I can modify the code in order for this to happen?

Thank you for your help!
Timon

question

All 11 comments

It looks like you did not upload an debug report. The debug report is important; it gives @retorquere your current BBT settings and a copy of the problematic reference as a test case so he can best replicate your problem. Without it, @retorquere is effectively blind. Debug reports are useful for both bug analysis and enhancement requests; in the case of export enhancements, I need the copy of the references you have in mind.

  1. If your issue relates to how BBT behaves around a specific reference(s), such as citekey generation or export, select at least one of the problematic reference(s), right-click it, and submit an BBT debug report from that popup menu. If the problem is with export, please do include a sample of what you see exported, and what you expected to see exported for these references.

  2. If the issue does not relate to references and is of a more general nature, generate an debug report by restarting Zotero with debugging enabled (Help -> Debug Output Logging -> Restart with logging enabled), reproducing your problem, and selecting "Send Better BibTeX debug report..." from the help menu.

Once done, you will see a debug ID in red. Please post that debug id in the issue here.

Thank you!

If you send a debug log as per point 1. above, I'll have the exact reference to play with, which will make it easier to get right.

I'd also need to see what the produced bibtex is for you. I can help getting a given bibtex output -- how your style renders it is not my area of expertise, that's best asked on tex.stackexchange.com.

:robot: this is your friendly neighborhood build bot announcing test build 5.2.18.6215 ("scripting update for #1466")

Install in Zotero by downloading test build 5.2.18.6215, opening the Zotero "Tools" menu, selecting "Add-ons", open the gear menu in the top right, and select "Install Add-on From File...".

@retorquere: Sorry for the delay. I was occupied for a while.

Here is the ID for the debug report: HCR4CZII-euc

This is my complete bibtex file copied into a .txt file because the forum does not accept a .bib file. The entry example from the debug report is the fourth from the bottom.
bibtex_file.txt

I hope this helps. Let me know if there are any more details I can give you.
Thank you for your help!

@retorquere Just letting you know that I am still interested in this. Can you give me an estimation about how long you will need to get back to this? This would be great for further planning.

Sorry, work has been overwhelming lately and I lost track of this issue. Can you pick out a single item that exhibits the problem and get me a debug log and a bib file as you think it should look, so with the corrections applied you think BBT should have made?

No worries I know exactly how busy work can get.

Now as you asked I picked a single item and send you a debug log. You will find it under this reference Code: I5A5AGVS-euc

This is my bib file:
bibtex_file_2.txt

The part we are looking at looks momentarily like this:

@misc{zotero-130,
  title = {Boltzmann-{{Konstante}} \textendash{} {{Wikipedia}}},
  note = {Zuletzt gepr{\"u}ft **2020-03-12T12:41:26Z**},
  howpublished = {\url{https://de.wikipedia.org/wiki/Boltzmann-Konstante}}
}

... but should rather look like this:

@misc{zotero-130,
  title = {Boltzmann-{{Konstante}} \textendash{} {{Wikipedia}}},
  note = {Zuletzt gepr{\"u}ft **12.03.2020**},
  howpublished = {\url{https://de.wikipedia.org/wiki/Boltzmann-Konstante}}
}

In words: The date should be in a dd.mm.yyyy format and separated by a period instead of a dash. Also I would like to get rid of the time, because I personally do not find it relevant. If getting rid of it is not an option I would prefer for it do be in a hh:mm format without the "T" and "Z" in it.

Thank you for your support!

Timon

P.S.: I believe this to be a relevant topic for more people than just me since it is quite common to add a reference date to online sources and time and date formats vary form country to country and underly personal preferences. Therefore your help is highly appreciated!

This should do it:

if (Translator.BetterBibTeX && item.itemType === 'webpage') {
  if (item.accessDate) {
    reference.add({ name: 'note', value: "Zuletzt gepr眉ft " + item.accessDate.replace(/^(\d+)-(\d+)-(\d+).*/, '$3.$2.$1') + " " });
  } 
  if (item.url) { 
    reference.add({ name: 'howpublished', bibtex: "{\\url{" + reference.enc_verbatim({value: item.url}) + "}}" });
  } 
}

although if you want easier localization, biblatex is going to be a much more pleasant experience if you can use it. No postscripting is required there.

How this further gets rendered by the style (such as the comma you mentioned) is not something BBT can influence because it has no knowledge of what style is selected in your pipeline. For style tweaks, https://tex.stackexchange.com is your best bet.

Wow! Thank you dear Mister! This was much appreciated help!

I will look into biblatex at times and see if it treats me any better.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings