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

Blank JSON export #8

Closed
ksummers92 opened this issue Jun 3, 2020 · 4 comments
Closed

Blank JSON export #8

ksummers92 opened this issue Jun 3, 2020 · 4 comments

Comments

@ksummers92
Copy link

I ran into an issue of the betobibtex creating a blank JSON. If I set BibTeXtoJSON to false, I would then get a .bib file that was not properly formatted for pandoc-citeproc to read (the error stated that there was a "," and whitespace was expected). However, the issue appears to have arisen from the lack of an author in one of the citations or an incomplete citation generally. Once the offending citation was removed from the group, the JSON was created normally.

@iandol
Copy link
Owner

iandol commented Aug 17, 2020

@ksummers92 -- sorry for the late reply. Yes, empty cite keys will stop the export from working. I have a smart search in Bookends which finds any refs that are empty:

Screenshot 2020-08-17 at 09 12 16

I could perhaps make a warning if the JSON ends up empty, but I don't have much other recourse as I just use pandoc-citeproc to generate the JSON itself.

@ksummers92
Copy link
Author

@iandol no problem. I guess I was just making it known that this could be a cause of blank JSON exports so that others will know a potential cause. It took me a bit to figure it out, so I just wanted to make the reason searchable for others. Feel free to close this issue as I believe that your search solution with Bookends will suffice for most people to at least narrow down a potential problem. Thank you.

@iandol
Copy link
Owner

iandol commented Aug 18, 2020

@ksummers92 -- I've made a quick blind edit to the applescript to check if the JSON is blank and warn the user, and not delete the BibTex, could you please try it and see if it works as expected (my applescript fu is weak). In Alfred you should be able to go to the workflow, edit the toBibtex.applescript, scroll down to line 221 and replace that section with this:

		-- Convert to JSON? JSON is much faster to parse for pandoc-citeproc
		if (toJSON is true) and (isCiteproc is true) then
			set cmd to cpPath & " -j " & quotedName & " > " & quotedJSONName
			do shell script cmd
			set sizeCheck to do shell script "du " & quotedJSONName & " | awk '{print $1}'"
			if (sizeCheck = "0") then
				display notification with title "JSON is Empty" subtitle "There may be a blank citekey in your references..."
			else
				do shell script "rm -f " & quotedName
				set output to output & "(to JSON)"
			end if
		end if

Does that seem to work? If so I can update the workflow officially...

@iandol
Copy link
Owner

iandol commented Aug 19, 2020

Actually that didn't work but I found using a try statement block catches the error and I now generate a warning display notification if JSON is empty, deleting the empty file. Thanks for the input!

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

No branches or pull requests

2 participants