retorquere / zotero-better-bibtex

Make Zotero effective for us LaTeX holdouts
https://retorque.re/zotero-better-bibtex/
MIT License
5.22k stars 285 forks source link

tex.enc_latex is not a function #2913

Closed peterstory closed 2 months ago

peterstory commented 2 months ago

Debug log ID

H8MI84Y6-euc/6.7.210-6

What happened?

I've been using the following postscript to add URLs to my BibTeX export:

if (Translator.BetterBibTeX) {
  if ((zotero.itemType == 'presentation') && (tex.referencetype == 'misc') && zotero.meetingName) {
    tex.referencetype = 'article'
    tex.add({name: 'journal', 'value': zotero.meetingName})
  }

  if ((zotero.itemType == 'webpage') && (zotero.url)) {
    tex.remove('howpublished')
    tex.add({name: 'note', bibtex: "{\\url{" + tex.enc_latex({value: zotero.url}) + "}}"})
  }
}

When viewing the diff of my latest export, I noticed that many entries are now missing their URLs. For example, this entry:

 @misc{advertisingstandardsauthorityASARulingTefincom2019,
   title = {{{ASA Ruling}} on {{Tefincom SA}} t/a {{NordVPN}}},
   author = {{Advertising Standards Authority}},
   year = {2019},
   month = may,
   urldate = {2021-06-30},
-  file = {/Users/pstory/Zotero/storage/W6MNGJXH/tefincom-sa-a19-547668.html},
-  note = {\url{https://www.asa.org.uk/rulings/tefincom-sa-a19-547668.html}}
+  file = {/Users/pstory/Zotero/storage/W6MNGJXH/tefincom-sa-a19-547668.html}
 }

I know that my postscript is running, because if I comment out tex.remove('howpublished') then howpublished appears in the export. So I don't understand why the tex.add() would have no effect on the export.

A screenshot of the associated info in Zotero:

image

And of my export settings:

Screenshot 2024-06-28 at 9 29 57 AM

Inspecting the debug log, I see messages like: (3)(+0000049): {better-bibtex worker:Better BibTeX error:} +29 postscript error: "[error: tex.enc_latex is not a function\nanonymous/result<@chrome://zotero-better-bibtex/content/worker/zotero.js?version=6.0.37&platform=mac&locale=en-US&clientName=Zotero&is7=false line 110390 > Function:23:48\nanonymous@chrome://zotero-better-bibtex/content/worker/zotero.js?version=6.0.37&platform=mac&locale=en-US&clientName=Zotero&is7=false line 110390 > Function:15:20\ncomplete@chrome://zotero-better-bibtex/content/worker/zotero.js?version=6.0.37&platform=mac&locale=en-US&clientName=Zotero&is7=false:111111:17\ngenerateBibTeX@chrome://zotero-better-bibtex/content/worker/zotero.js?version=6.0.37&platform=mac&locale=en-US&clientName=Zotero&is7=false:112951:7\ngenerateBibTeX@chrome://zotero-better-bibtex/content/worker/zotero.js?version=6.0.37&platform=mac&locale=en-US&clientName=Zotero&is7=false:113556:7\ndoExport@chrome://zotero-better-bibtex/content/resource/Better%20BibTeX.js:1991:5\nstart@chrome://zotero-better-bibtex/content/worker/zotero.js?version=6.0.37&platform=mac&locale=en-US&clientName=Zotero&is7=false:113720:7\n]"

github-actions[bot] commented 2 months ago

:robot: this is your friendly neighborhood build bot announcing test build 6.7.210.2913.6483 ("fixes #2913")

This update may name other issues, but the build just dropped here is for you; it just means problems already fixed in other issues have been folded into the work we are doing here. Install in Zotero by downloading test build 6.7.210.2913.6483, opening the Zotero "Tools" menu, selecting "Add-ons", open the gear menu in the top right, and select "Install Add-on From File...".

peterstory commented 2 months ago

I tested the build and it works great. Thank you!