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

Better CSL does not extract extra variables #2963

Closed
nateinla opened this issue Aug 29, 2024 · 23 comments
Closed

Better CSL does not extract extra variables #2963

nateinla opened this issue Aug 29, 2024 · 23 comments
Labels

Comments

@nateinla
Copy link

nateinla commented Aug 29, 2024

Debug log ID

8HMFT7MM-refs-euc/6.7.226-7

What happened?

Hi there. Thanks so much for this terrific plugin!
I'm trying to get add a postscript to BBT to export a CSL variable from the Extra field. However, any script I add is exported as as the field "postscript": [code]. I've included a short debug script in the debug example I uploaded.

I expect this has to do with the "ae:sql:get: undefined is not a string but a undefined" error, but I'm a total noob.

Thanks in advance for your guidance!

@retorquere
Copy link
Owner

I'm trying to get add a postscript to BBT to export a CSL variable from the Extra field. However, any script I add is exported as as the field "postscript": [code]. I've included a short debug script in the debug example I uploaded.

I can't yet reproduce this. I get the simple log message as expected. I don't yet know by what path this could end up as a field "postscript" in the output CSL. Can you send a new log and tick the "include cache" option?

I expect this has to do with the "ae:sql:get: undefined is not a string but a undefined" error

No relation.

@nateinla
Copy link
Author

Debug log ID

K9FUKTI3-euc/6.7.226-7

Resubmitted with cache attached. Thanks!

@retorquere
Copy link
Owner

A debug build will drop here in a few minutes, please install it, export again, and send a new log.

Copy link

🤖 this is your friendly neighborhood build bot announcing test build 6.7.226.6867 ("logging")

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.226.6867, opening the Zotero "Tools" menu, selecting "Add-ons", open the gear menu in the top right, and select "Install Add-on From File...".

@nateinla
Copy link
Author

Debug log ID

R52FBFKP-euc/6.7.226.6867-7

@retorquere
Copy link
Owner

retorquere commented Aug 29, 2024

Can you reset the cache from the BBT preferences (under misc), export again, and send a new log?

@nateinla
Copy link
Author

Debug log ID

K6J9AYUD-apse/6.7.226.6867-7

@retorquere
Copy link
Owner

I don't see the translator running. A new build will drop soon, please generate a new log from that.

Copy link

🤖 this is your friendly neighborhood build bot announcing test build 6.7.226.6870 ("log translator id")

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.226.6870, opening the Zotero "Tools" menu, selecting "Add-ons", open the gear menu in the top right, and select "Install Add-on From File...".

@nateinla
Copy link
Author

Debug log ID

NW6FZ38F-euc/6.7.226.6870-7

@retorquere
Copy link
Owner

NW6FZ38F-euc shows the CSL to be

{"id":"11spreadmoderndemocracy_","type":"article-journal","language":"en","source":"Zotero","title":"11. The spread of modern democracy","citation-key":"11spreadmoderndemocracy_"}

before and after the postscript has ran. A new build will drop soon, please generate a new log, but can you also post the actual output you are getting?

Copy link

🤖 this is your friendly neighborhood build bot announcing test build 6.7.226.6875 ("log final result")

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.226.6875, opening the Zotero "Tools" menu, selecting "Add-ons", open the gear menu in the top right, and select "Install Add-on From File...".

@nateinla
Copy link
Author

Debug log ID

JCYNWNHC-euc/6.7.226.6875-7

json attached. Thanks!
Exported Items.json

@retorquere
Copy link
Owner

You are exporting as BetterBibTeX JSON, which is BBTs debug format (and it's also used for automation). You want Better CSL JSON.

@nateinla
Copy link
Author

nateinla commented Aug 29, 2024

Thanks. I've set the export format to Better CSL JSON, and I don't see the postscript anymore.

But, I've tried adding my actual JS to the scripting section and I'm still not seeing my CSL variable ("GSCC") listed under the "notes" field. JSON attached.
Exported Items.json

Here's the script I've added:

if (Translator.BetterBibTeX) { if (this.extraFields && this.extraFields.extra) { let citeCount = this.extraFields.extra.find(field => field.name === 'GSCC'); if (citeCount) { this.add({ name: 'GSCC', value: citeCount.value }); } } }

FYI, my ultimate goal is to get this field to show up in Obsidian using the Zotero Integration plugin.

@retorquere
Copy link
Owner

retorquere commented Aug 30, 2024

The script you posted will only do stuff in the Better BibTeX translator, and .add is specific to the TeX translators; CSL uses simple object manipulation. You want something like

if (Translator.BetterCSL) {
  if (extra.kv.GSCC) csl.GSCC = extra.kv.GSCC
}

@retorquere
Copy link
Owner

listed under the "notes" field.

I am not sure what you mean by this.

@nateinla
Copy link
Author

nateinla commented Aug 30, 2024

listed under the "notes" field.

I am not sure what you mean by this.

In the JSON I see the CSL variable under "note":"GSCC: 0021819 \nmy-note: testing" which includes everything in the Extra field.

I tried the script

if (Translator.BetterCSL) {
  if (extra.kv.GSCC) csl.GSCC = extra.kv.GSCC
}

But that's not pulling it out. I looked at your Extra fields doc and the Scripting doc, but I'm lost. Should the code above be enough to pass a new CSL variable that's used in the Extra field?

@retorquere
Copy link
Owner

8HMFT7MM-refs-euc/6.7.226-7 does not contain a line

GSCC: something

so there's nothing to pull out.

@retorquere
Copy link
Owner

But there is an error somewhere. I'll look into it tomorrow.

@retorquere retorquere changed the title postscript creating a variable instead of running Better CSL does not extract extra variables Aug 30, 2024
retorquere added a commit that referenced this issue Aug 30, 2024
retorquere added a commit that referenced this issue Aug 30, 2024
retorquere added a commit that referenced this issue Aug 30, 2024
Copy link

🤖 this is your friendly neighborhood build bot announcing test build 6.7.226.6896 ("testcase")

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.226.6896, opening the Zotero "Tools" menu, selecting "Add-ons", open the gear menu in the top right, and select "Install Add-on From File...".

@retorquere
Copy link
Owner

retorquere commented Aug 31, 2024

This will do it now:

if (Translator.BetterCSL) {
  if (extra.raw.gscc) csl.GSCC = extra.raw.gscc
}

the .kv variables only support equivalents of Zotero fields, the .raw fields have any colon-separated value in extra. Variable names are always lowercased.

retorquere added a commit that referenced this issue Aug 31, 2024
@nateinla
Copy link
Author

Thanks! GSCC is showing up in the json export.

Now I need to figure out how to get the Zotero Integration plugin to recognize it. For another day!

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

No branches or pull requests

2 participants