hans / obsidian-citation-plugin

Obsidian plugin which integrates your academic reference manager with the Obsidian editor. Search your references from within Obsidian and automatically create and reference literature notes for papers and books.
MIT License
1.04k stars 77 forks source link

Pull PubMed ID / arbitrary fields from underlying bibtex? #198

Closed hbhargava7 closed 1 year ago

hbhargava7 commented 1 year ago

Is your feature request related to a problem? Please describe. Outstanding work with this project. For Life Science / Biomedical research, the Pubmed ID (PMID) / Pubmed Central ID (PMCID) is king. It enables rapid accession, and is also required for things like NIH grants.

It would be great to integrate the ability to pull the pmid and pmcid fields out of the underlying bibtex file. In fact – I'd love to see the ability to pull arbitrary fields from the bibtex @ARTICLE definitions.

Describe the solution you'd like In addition to the list of variables that can be referenced (citekey...zoteroSelectURI), allow arbitrary handles to be specified that correspond with fields in the bibtex.

Describe alternatives you've considered Workaround could be to run a script to move the PMID / desired field into one of the supported field.s

Additional context Add any other context or screenshots about the feature request here.

hbhargava7 commented 1 year ago

For what it's worth, I'm using Paperpile to live generate a bibtex file in Google Drive, which is read into the plugin.

hbhargava7 commented 1 year ago

Okay resolving my own issue here. From the note in the editor

Advanced users may also refer to the {{entry}} variable...

I thought this might be possible, but unfortunately there doesn't seem to be a reference on what the structure of entry objects looks like or how to explore it.

Thanks to this post I was able to retrieve the object structure from the developer console (by querying app.plugins.plugins['obsidian-citation-plugin'].library.entries['citekey'].data.creators.editor[0], replacing citekey with a citekey from my library). This revealed the object structure:

creators : 
  author : [] // list of authors
fields : 
  abstract : ...
  doi : ...
  pmc : <PMC ID>
  pmid : <PUBMED ID!>

Which made the solution trivial for pubmed id and any other non-exposed fields:

{{entry.data.fields.pmid}}

This is also very exciting to me because it paves the way for arbitrary field interoperability -- like if paperpile introduces support for exporting their URLs. Now I just need to wrap my head around Handlebars syntax...

hbhargava7 commented 1 year ago

Tag #44 #42 regarding advanced templating.

cchmagyar commented 1 year ago

How are you live generating a bibtex file in Google Drive?

hbhargava7 commented 1 year ago

How are you live generating a bibtex file in Google Drive?

See https://paperpile.com/h/automatic-bibtex-export/

Phenomenal feature I didnt know existed till I needed it. Will likely move to github soon if the plugin can take a URL.

cchmagyar commented 1 year ago

How are you live generating a bibtex file in Google Drive?

See https://paperpile.com/h/automatic-bibtex-export/

Phenomenal feature I didnt know existed till I needed it. Will likely move to github soon if the plugin can take a URL.

Sweet. Thank you!

cchmagyar commented 1 year ago

Do you use a template for Obsidian ..annotated bibliography?

hbhargava7 commented 1 year ago

Not yet — 24h into Obsidian now. Open to recommendations!

orionpilot commented 1 year ago

Just highlighting #100 regarding accessing other elements of the underlying bibtex entries. Some variables like {{abstract}} have shortcut variables already defined. But if there is a variable within a bibtex entry which does not have a shortcut, like your PMID, then {{entry.data.fields.FIELD}} is the way you access it. Looks like you found that answer if a more roundabout way than I did!