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 76 forks source link

Title Updates Incorrect/Inconsistent #258

Open brandonbrinkley opened 7 months ago

brandonbrinkley commented 7 months ago

Describe the bug Title updates in Zotero are not being updated correctly/consistently in Obsidian. This includes both the {{title}} and {{titleShort}} variables. Please consider the examples below for tested behavior.

Examples:

To Reproduce

Prerequisites for this test:

  1. The {{title}} and {{titleShort}} variables need to be in the Literature Note template (title and/or content) in the plugin settings in Obsidian.

Steps to reproduce the behavior:

  1. Create a new book with the title and short title "The red balloon" (only first letter of first word is capitalized).
  2. Export the .bib file.
  3. In Obsidian, use the "Citations: Open literature note" command, confirm the capitalization in the popup window.
  4. Click on the book to create the new Literature Note, noting the case of the title.
  5. Delete the Literature Note.
  6. Update the book's title and short title to "The Red Balloon" in Zotero (first letter of all words is capitalized).
  7. Export .bib file again.
  8. Verify the new capitalization by opening the .bib file in a text editor.
  9. Use the "Citations: Open literature note" command again, verifying that the capitalization didn't change in that popup window.
  10. Click on the book to create the new Literature Note, noting that the title and short title are still in the original case.
  11. Delete the Literature Note.
  12. Update the book's title and short title to "THE Red Balloon" in Zotero (first word is now all-caps).
  13. Export the .bib file.
  14. Verify the new capitalization by opening the .bib file in a text editor.
  15. Use the "Citations: Open literature note" command again, verifying that the capitalization didn't change in that popup window except for the all-caps word.
  16. Click on the book to create the new Literature Note, noting the same case as in the previous step.
  17. Delete the Literature Note (just to clean up the test data).

NOTE: This only seems to be true for the title and short title fields. The year and the abstract are two other fields I've tested and they work fine. Also, special characters do get updated correctly (like changing a "-" to "--").

Console output N/A

Expected behavior The title should be updated reflecting the correct case.

Screenshots None provided

Platform

Additional context None

orionpilot commented 7 months ago

Are you refreshing the database between the creation of the literature notes? I think that the pop-up window does not recognize the new capitalization since it has not been refreshed with the new version of the file (in the same way that a new entry does not get recognized by the plugin without a refresh). Also, what do the .bib entries look like after export? I'm not sure how Zotero handles the export, but this sort of looks like normal bibtex behaviour regarding capitalization, see my comment here and #191.

brandonbrinkley commented 7 months ago

@orionpilot I was refreshing the database every time initially, but then I noticed that for those test cases where the capitalization did change, it did so automatically without a refresh.

brandonbrinkley commented 7 months ago

@orionpilot Also, I checked the .bib file with a text editor and the capitalization changes were reflected after export.

orionpilot commented 6 months ago

OK that's good to know. I am not sure what's going on when the capitalization is changing automatically without a refresh. I will say that I don't use Zotero so can't exactly replicate but I do still think this is a bibtex issue based on a quick test. When you saw that the captilization changes in the export, does the title look like {title = The Big Red Balloon} in the .bib? And does this get rendered as The big red balloon in Obsidian? If this is true, then this is just how bibtex is rendered/handles capitalization. You can force capital letters by using {c}urly brackets. This might be a Zotero setting to change.

tl;dr: The Big Red Balloon in the bib file gets rendered as The big red balloon but The {B}ig {R}ed {B}alloon will be rendered as The Big Red Balloon. This is normal bibtex behaviour.

brandonbrinkley commented 6 months ago

I just looked at it, and the last test data was "The RED Balloon" in Zotero. I checked the .bib file and found: title = {The {RED} Balloon}

I then changed it to the normal first-letter capitalization and re-exported, and found this: title = {The Red Balloon}

orionpilot commented 6 months ago

That was what I was expecting was happening. Everything is getting rendered as expected in bibtex/by the plugin. I don't know what the solution is to get capitalization as you want from Zotero. Quick Google search shows that handling capitalization is a bit tricky, see the FAQ from the BetterBibTeX website (since I am assuming that's what you are using to export to bibtex). Personally, I've sometimes seen entires when imported to my library automatically having curling braces to force the capitalization, but its not at all universal.