plk/biber

Is there a way to convert from standard bibtex to biblatex using --tool?

Closed this issue · 2 comments

Some of the entries I'm receiving (from google scholar etc.) are formatted with the standard bibtex syntax (dates etc). Is there some simple and robust way to convert these to biblatex form using fiber?

My actual use case is implemented in emacs and doesn't output to a .bib file, but I can't seem to find an existing elisp function to convert bibtex entries and don't want to reimplement it right now, so I'm considering just writing a file with the single entry, converting it using an external tool, and then bringing it back into a buffer.

Thanks!

plk commented

This should be possible, yes. biber in tool mode can input .bib files change them using sourcemaps and/or the various options of biber on the command line and output bibtex format again. This could be called from elisp and inserted into the buffer. You can tell biber to output to STDOUT if necessary.

Thanks, I was able to do this by using a temporary file in zsh with =(echo 'bibtex entry here') to pass it to the stdin of biber. Using a normal pipe didn't seem to work for buffering reasons, but maybe there's a better way.

In elisp this looks like

(with-temp-buffer
		     (list :exit-status
			   (call-process-shell-command
			    (concat "biber --tool -q --output-file=- =(echo -n "
				    (shell-quote-argument bib)
				    ")")
			    nil t)
			   :output
			   (buffer-string)))