Question about linked BibTex file and formatting

A place for users to ask each other questions, make suggestions, and discuss Bookends.
Post Reply
postdoctoral
Posts: 23
Joined: Mon Dec 27, 2021 9:38 pm

Question about linked BibTex file and formatting

Post by postdoctoral »

Hi all.
Let me start by saying that I'm a little out of my depth here, so apologies if the solution is under my nose.

I've been using the BE function to link, and update via shift-CMD-L, a .bibtex file. Fantastic function, by the way. I love that I was able to customize the output to include notes and short titles via the Format Manger.

If I inspect the BibTex file with a text editor, it shows the title with what looks to me like ordinary title capitalization practices, like:

title = {Paranoid Reading and Reparative Reading}

If I use the same .bibtex file to generate a pandoc-style citation in Zettlr, and convert to Doc (using Pandoc), the formatting is perfect, with the three Rs of Reading, Reparative and Reading capitalized.

However, if I use the Obsidian citations plug-in to make markdown literature note in Obsidian, only the first letter is capitalized in the output, which comes out as "Paranoid reading and reparative reading".

I use the following syntax to obtain the title of the markdown literature note from the .bibtex file that shows [last name], [year], [short title]:

{{#each entry.author}}{{#if @first}}{{#if this.family}}{{this.family}}{{#unless @last}} et al.{{/unless}}{{else}}{{../authorString}}{{/if}}{{/if}}{{/each}}, {{#if year}}{{year}}{{else}}no date{{/if}}, {{#if entry.titleShort}}{{entry.titleShort}}{{else}}{{title}}{{/if}}

If I manually modify the .bibtex file to read:

title = {Paranoid {Reading} and {Reparative} {Reading}}

then the Obsidian plug-in outputs the text in the correct way, with capitals.The Pandoc conversion still works as expected.

This would seem to suggest that if I want proper capitalization I would have to get Bookends to produce a .bibtex file that has each capitalized word surrounded by a set of curly brackets. Is there a way to do that? (I noticed there is an option to do that in the BetterBibTex plugin on Zotero, fwiw)

Alternatively, can anyone with knowledge of the Obsidian plug-in and the system it uses maybe suggest if there is a way to ensure on their end that the formatting is retained?

Or, worst case scenario, does anyone know of a reasonably easy way to automate the adding of curly brackets directly to the text file?

Thank you!
iandol
Posts: 468
Joined: Fri Jan 25, 2008 2:31 pm

Re: Question about linked BibTex file and formatting

Post by iandol »

I can only add useful information for the worst case scenario. I use Pandoc and have set up macOS launchd to run a script every time the BibTeX file is modified by Bookends (more details here: viewtopic.php?p=25644#p25644 ). In my case I run a custom script that converts BIB to JSON as it is much faster when formatting, and triggers another script written in Ruby to case-protect scientific keywords. Now my case preserving script: https://github.com/iandol/dotfiles/blob ... fixCase.rb would not work for your situation (as it uses word lists), but it gives you a pointer about automation. You could write a script to case protect the whole title as a hack and have it auto-run on every update by bookends...

The real problem lies with Obsidian, which appears to use some baked-in CSL style which doesn't preserve case, so that's where you should look...
postdoctoral
Posts: 23
Joined: Mon Dec 27, 2021 9:38 pm

Re: Question about linked BibTex file and formatting

Post by postdoctoral »

ugh. Thank you for your answer. By the way, I'm posting another smaller question that I suspect you'll know the answer too as well but I'll make a separate thread for future reference.
postdoctoral
Posts: 23
Joined: Mon Dec 27, 2021 9:38 pm

Re: Question about linked BibTex file and formatting

Post by postdoctoral »

iandol wrote: Mon Jan 31, 2022 5:31 am I use Pandoc and have set up macOS launchd to run a script every time the BibTeX file is modified by Bookends (more details here: viewtopic.php?p=25644#p25644 ).
@iandol, thank you for pointing me to using Pandoc to convert .bib into .json, that's turning out to be very useful. I have another (esoteric) question: do you (or anyone) know of any way to convert BIB into "BetterBibTex JSON"? I am not really sure what that is and how it relates to ordinary CSL JSON. I know it's one of the output options from Zotero's ubiquitous Better BibTex plug-in. And now I have a nice Obsidian plug in that only accepts that (BBT JSON) as input, but I'd love to use it with my Bookends, not with Zotero. I suspect the answer to this one is a flat no, but as always, TIA.
iandol
Posts: 468
Joined: Fri Jan 25, 2008 2:31 pm

Re: Question about linked BibTex file and formatting

Post by iandol »

Yeah, according to BetterBibTeX docs:

https://retorque.re/zotero-better-bibte ... anslators/

CSL-JSON and BBT-JSON are not equivalent. I have no idea what the differences are, you'd have to try to export each and see what it looks like.

I assume you mean this tool:

https://github.com/sashinexists/zotero-to-obsidian

I think one thing you can do is open an issue on that repo asking for CSL-JSON support, though maybe there is a reason she/he chose to use the proprietary JSON format?

Of course, Bookends has a nice Applescript interface, and you can also theoretically (skills pending) build something that would export from BE to JSON directly or whatever Obsidian requires. My Alfred scripts pull in refs via Applescript and transform to JSON (Alfred uses JSON internally). There is already an OPML exporter, does Obsidian support OPML?
postdoctoral
Posts: 23
Joined: Mon Dec 27, 2021 9:38 pm

Re: Question about linked BibTex file and formatting

Post by postdoctoral »

Thank you. I meant this plug in:

https://github.com/stefanopagliari/bibnotes

I like it because it gives the option to have a literature note in obsidian for each entry in your library and to one-click non-destructively update any changes in the entire library if, say, you fix some metadata. If you use zotero’s notes system it also imports those. So it’s a neat gadget, but the guy who made it made it with BBT JSON apparently for no particular reason. (actually, scrap that: I think the reason he chose BBT-JSON is because it bakes into the export a field with the date and time each entry was last modified, which the plug in then uses to selectively only touch the notes that need updating and leave the others alone. From a very cursory quick look I gave, neither BE's "native" .bib export nor the alternative "standard" CSL-JSON include a date modified field for each entry.)

I have no idea whether obsidian supports OPML, I’ll look. (edit: apparently it doesn't. I'm really curious about your Alfred scripts, which look great. I wish Alfred had a free trial for their Workflows function, though...)

The thing is, ultimately I don’t care about obsidian specifically, and ideally I don’t want to switch from Bookends to Zotero after many years. But what I do want is for my BE library and its PDF annotations to come alive in the form of interlinked .md files composed after a template of my own design. And I love it when things happen automatically. So far the best avenues that I found are this BibNotes Formatter plug-in (but the roadblock is the BBT JSON input) or the Highlights.app “sidecar” feature (the roadblock is you cannot customize the .md template and any subsequent update to annotations will overwrite any changes you made manually to the sidecar file).

The trouble is I don’t have the skills to build any of what I want from scratch, otherwise I could imagine that making my own custom Obsidian plug-in would not be out of the question. Perhaps I have to seriously look into Alfred, AppleScripts and KeyboardMaestro — I’m not too familiar with the former and I see that it keeps coming up in these discussions…
iandol
Posts: 468
Joined: Fri Jan 25, 2008 2:31 pm

Re: Question about linked BibTex file and formatting

Post by iandol »

You can open an issue and ask that author, that's your best bet.

Learning the tools to roll something yourself does take time and patience, certainly more than the time to manually edit your JSON in the short term :lol: but such skills are useful and satisfying in the long term...
postdoctoral
Posts: 23
Joined: Mon Dec 27, 2021 9:38 pm

Re: Question about linked BibTex file and formatting

Post by postdoctoral »

In the end I took a couple of days to give myself a crash course in AppleScript -- fun! -- and I've been able to do all of what I wanted and more. Bookends' scriptability has cured me of any latent desire to move to Zotero, so that's good. Thanks!
Post Reply