retorquere / zotero-better-bibtex

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

Using the Extra field in the exported Citation Key #1571

Closed LloydThinks closed 3 years ago

LloydThinks commented 4 years ago

How do I add a Extra field item to the Citation key format?

I have a Zotero item with the Extra field set to "vns= RET" and I want to use the "vns" field in the "Citation key format" field. Is this possible? I found the "[Extra]" option, but that is the entire Extra field, and from what I understand of Zotero: the Extra field can contain a lot more than just what I put there. How do I get just the custom defined "vns" part?

Report ID: RBHI8U7L-euc

Many thanks! Lloyd

LloydThinks commented 4 years ago

For example, is the use of :regex("pattern", "replacement") noted in [1] supported? I'm sure with a regex I could find a way to find that text and extract it.

[1] https://docs.jabref.org/setup/bibtexkeypatterns

LloydThinks commented 4 years ago

I am using the ZotFile plugin for renaming my files, and I accessed this field using the following preferences config:

{
  "1": {
    "default": {
      "field": "extra",
      "operations": [
        {
          "function": "exec",
          "regex": "vns: *([^;\\n\\r\\f]+)",
          "group": 1
        }
      ]
    }
  }
}

This allows me to set the ZotFile renaming rule to {%a}_{%1}_{%y} in which the {%1} is the regex above that finds the vns variable in the Extra field.

Hoping for something similar in Better BibTex.

retorquere commented 3 years ago

Sorry I left this to linger so long. A new build will drop here in 10 minutes or so, can you right-click an entry that has these lines in the extra field and send a new log? RBHI8U7L-euc has been removed by now, sorry.

github-actions[bot] commented 3 years ago

:robot: this is your friendly neighborhood build bot announcing test build 5.3.3.785 ("allow lines from extra field in citekey")

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

LloydThinks commented 3 years ago

Hi @retorquere . Thank you for getting back to this request! No apologies needed, just thank YOU for your work.

Request ID: NICUI6Z2-euc

retorquere commented 3 years ago

A new build will drop momentarily. Try [auth:postfix=_][extra=vns:postfix=_][year].

github-actions[bot] commented 3 years ago

:robot: this is your friendly neighborhood build bot announcing test build 5.3.3.790 ("extra field extraction")

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

LloydThinks commented 3 years ago

It works! I just have to right-click and "Refresh BibTex key".

retorquere commented 3 years ago

Correct -- pattern changes have not caused a refresh since Zotero 4. Thanks for the confirmation, will roll this out now.