anoopkcn / obsidian-reference-map

Reference and citation map for literature review and discovery
GNU General Public License v3.0
200 stars 6 forks source link

Unable to find a paper when there is no whitespace after a citekey #13

Closed irzhegalova closed 1 year ago

irzhegalova commented 1 year ago

hey!

I was using a citekey at the end of the sentence like that: [@interestingPaper_Year]. And for some reason, this plugin was unable to parse a citekey. I added a whitespace like that [@interestingPaper_Year] . and then the paper was parsed into Reference Map automatically. The same behaviour was noticed when creating metadata template {{author}}, {{year}} %%[{{id}}] %%, I was forced to add that whitespace in order for paper to parse into the system.

It would also be great help for me if you can explicitly add {{citekey}} to allowed metadata fields

p.s. I was looking for something to manage my zotero lib from obsidian and accidentally bumped up into your plugin. I love it, great work!

anoopkcn commented 1 year ago

Hi, I will look into the issue.

It would also be great help for me if you can explicitly add {{citekey}} to allowed metadata fields

You can use the {{id}} metadata field; this is equivalent to {{citekey}}. Or did I misunderstand your statement above? Note:: for batch metadata operations {{id}} will return empty.

anoopkcn commented 1 year ago

This is fixed in the latest release. Please test it.

Screenshot 2023-01-22 at 20 33 16
irzhegalova commented 1 year ago

@anoopkcn thank you for a quick fix, it works well now!

Regarding {{id}} you understood me perfectly, but unfortunately {{id}} is not always equivalent to citekey.

Let's say I added some doi to my obsidian note. Reference map will recognize it as a paper and create an entrance. But its key will be doi, not citekey. Have a look at this example: I added https://doi.org/10.1038/s41419-020-03238-7 with template {{author}}, {{year}} %%[{{id}}] %% I will receive the following: M. Schank, 2020 %%[10.1038/s41419-020-03238-7] %%

anoopkcn commented 1 year ago

Oh yes, I see what you mean now. Currently, {{citekey}} is only available for references you have in the Zotero library. I will think of a way to construct citekey for references not in the Zotero library. I have a couple of ideas about this. The biggest problem in implementing this is maintaining consistency between zotero bibtex citekey format and whatever format I implement for references(since better bibtex doesn't have a public typescript package). That is a long way of saying it might take a bit of time for me to implement this feature 😁

irzhegalova commented 1 year ago

It is harder than that :) if I cite a paper using doi although HAVING it in my library: https://doi.org/10.1016/j.cell.2022.11.001 (citekey @LOPEZOTIN2023243) Refmap will recognize it but when using the same template {{author}}, {{year}} %%[{{id}}] %% return C. López-Otín, 2022 %%[10.1016/j.cell.2022.11.001] %% but not C. López-Otín, 2022 %%[@LOPEZOTIN2023243] %% but anyway, I got your point. It is not a crucial thing, but still a little bit of pain for me

anoopkcn commented 1 year ago

In the next patch, I can add a setting to convert the reference ids to citekey if the references are present in the Zotero library. This could solve the problem you specified in the last message.

irzhegalova commented 1 year ago

it would be great, thank you so much!

anoopkcn commented 1 year ago

Hi @irzhegalova, I added this feature in the latest version(Reference-Map is now available in the community plugins so you can simply do an update) behaviour: If you have a DOI in the markdown file Reference-Map will look for the Citekey in the Zotero library; if it finds the CiteKey, it will substitute the {{id}} for that CiteKey instead of the DOI. The index cards will also show a link to the Zotero entry.

NOTE: you have to enable this in the settings called Find CiteKey from ID.