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

[Feature Request] Customizable Bibtex Key #526

Closed
thequilo opened this issue May 13, 2024 · 4 comments
Closed

[Feature Request] Customizable Bibtex Key #526

thequilo opened this issue May 13, 2024 · 4 comments
Labels
extension-dev Extension related.

Comments

@thequilo
Copy link

Correct me if I'm wrong, but I think it is currently impossible to customize the bibtex key. To match my current zotero setup, I would like to customize the bibtex keys to match those generated by zotero's betterbibtex integration.

I would also be willing to contribute a PR if I'm shown the correct place to start. I'm not an experienced JS dev, though.

@thequilo thequilo added the feature-request New feature request label May 13, 2024
@GeoffreyChen777
Copy link
Member

Hi, could you please describe what kinds of format do you want?

@thequilo
Copy link
Author

In the betterbibtex zotero plugin I have this configuration: auth + year + "_" + shorttitle(3,3), which results in, for example, Levenshtein1965_BinaryCodesCapable.

To match zotero's keys exactly, the title would have to be shortened to three words with unimportant words ignored. For example:

  • "From WER and RIL to MER and WIL: Improved Evaluation Measures for Connected Speech Recognition" -> Morris2004_WERRILMER

@GeoffreyChen777
Copy link
Member

OK, I would suggest you implement this in a hook extension, it's unnecessary to PR the main app.

https://paperlib.app/en/extension-doc/ext-types/hook-ext.html

We have some hooks for reference exporting. I would suggest you investigate these hooks:

https://paperlib.app/en/extension-doc/process-hook.html#citeobjcreatedinexportbibitem
https://paperlib.app/en/extension-doc/process-hook.html#citeobjcreatedinexportbibtexkey
https://paperlib.app/en/extension-doc/process-hook.html#citeObjCreatedInExportBibTexBody

The reference exporting logics are at here: https://github.com/Future-Scholars/paperlib/blob/main/app/renderer/services/reference-service.ts

Basically, let's use citeobjcreatedinexportbibtexkey hook as an example, if you hook this point, your function in the extension will receive an instance of Cite, and an instance of PaperEntity. the paperEntity contains all info of this paper. You can create your preferred bibkey, and overwrite the citation-key of the cite instance. After that, return the new cite instance, and you will get what you want.


Some useful source codes:

"citation-key": citeKey,

if (this._hookService.hasHook("citeObjCreatedInExportBibTexKey")) {
[cite, paperEntities] = await this._hookService.modifyHookPoint(
"citeObjCreatedInExportBibTexKey",
60000, // 1 min
cite,
paperEntities
);
}

@GeoffreyChen777 GeoffreyChen777 added extension-dev Extension related. and removed feature-request New feature request labels May 13, 2024
@GeoffreyChen777
Copy link
Member

As this can be achieved via extension, I will close this for now.

If you have any questions about the extension, feel free to tell me.

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

No branches or pull requests

2 participants