zotero-better-bibtex: [Bug]: missing field breaks import

Debug log ID

J2GQXW4D-refs-euc

What happened?

The function “Import from Clipboard” stopped working for me. Currently using Zotero 6.0.19, and disabling BetterBibTeX makes the function work again.

I semi-automatically create items using this function and lines of text created automatically by the browser, such as the example below:

@techreport{TBD,  title = {Report number 2PTE3 - 3D transport model under operative regime},  , number = {2PTE3},  institution = {{Research Institute X}},  url = {https://website.org/?uid=2PTE3},  Accessed = {2023-01-13}}

Now, when attempting an import, Zotero creates a note instead with comments such as: " Import errors found:

  • line 1, column 127: Expected “%”, Optional Horizontal Whitespace, Optional Whitespace, [\r\n], [_:a-zA-Z0-9-], or [})] but “,” found. "

Just to be clear, the found error is not always the same.

I already tried selecting “no” in both “Sentence-case titles on import” and “Insert case-protection for braces”, but it does not change the problem. I did notice, however, that after attempting an import the selector for “Sentence-case titles on import” automatically changes to “yes”.

Any ideas how to remedy this?

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 27 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Second, about the bookmarklet modifications: thanks a lot for the help! I tried to use your improved version, but it was missing the var title_tex definition command. I’ve fixed it and now it works perfectly! Thanks again.

I don’t think that would work, you’re applying my text2latex after doing your own tex conversions, and those backslashes that end up in title_tex would end up escaped. tltle_tex should be removed entirely.

javascript:"use strict";(function(){const mapping={'#':'\\#','$':'\\$','%':'\\%','&':'\\&','/':'\\slash','<':'$<$','>':'$>$','\\':'\\textbackslash','^':'\\^',_:'\\_','{':'\\{','}':'\\}','~':'\\textasciitilde'};function text2latex(t){return t.replace(/./g,c=>mapping[c]||c)}var _document$querySelect,_document$querySelect2,_document$querySelect3;function copyToClipboard(text){window.prompt("Copy to clipboard: Ctrl+C, Enter",text)}function jsDate2bibTex(date){var dd=date.getDate();var mm=date.getMonth()+1;var yyyy=date.getFullYear();if(dd<10){dd="0"+dd}if(mm<10){mm="0"+mm}return yyyy+"-"+mm+"-"+dd}function date2YearTex(date){var yyyy=date.getFullYear();return ""+yyyy}var title=document.title;var url=document.URL.replace('default.aspx','');var number=url.replace('https://website.org/?uid=','');var author_tag=document.querySelector("[name=author]");var author=author_tag==null?"":author_tag.content;var today=new Date;var urldate=jsDate2bibTex(today);var publishedTime=(_document$querySelect=document.querySelector('meta[property="article:published_time"'))===null||_document$querySelect===void 0?void 0:_document$querySelect.getAttribute("content");var someTimeTag=(_document$querySelect2=document.querySelector("time[datetime]"))===null||_document$querySelect2===void 0?void 0:_document$querySelect2.getAttribute("datetime");var someTimeTagWithoutDatetime=(_document$querySelect3=document.querySelector("time"))===null||_document$querySelect3===void 0?void 0:_document$querySelect3.innerHTML;var lastModifiedTime=document.lastModified;var pageTime=new Date(publishedTime||someTimeTag||someTimeTagWithoutDatetime||lastModifiedTime);var date=jsDate2bibTex(pageTime);var year=date2YearTex(pageTime);var title_key=title.replace(/[^0-9a-z]/gi,"");var citationKey='TBD';var type="@techreport";var filename=":./references/"+window.location.pathname.slice(1).replace(/\//g,"-")+".html:html";var bibTexEntry=type+" {"+citationKey+",\n  title = {"+text2latex(title)+"},\n "+(author?"  author = {"+author+"},\n":"")+" ,\n number = {"+number+"},\n  institution = {{Research Institute X}},\n  url = {"+url+"},\n  Accessed = {"+urldate+"}\n}";copyToClipboard(bibTexEntry)})();

Unfortunately, there is one problem still with the “Import from Clipboard” function.

This is not the problem BTW. It’s just an import error, import from clipboard just calls the importer. The same problem would occur if the same content were imported from a file.

The field “Accessed” gets written as tex.accessed in Extra, instead of filling the correct field.

Translators cannot set the accesseDate field directly. After import, you can right-click the item and select “Better BibTeX” -> “Copy date-added…”