I found some interesting behavior that I think I have narrowed down to the function bibtex-completion-get-value
I tried to capture all of my notes from my bibtex file into an org roam node for a bibliographic entry using the following code:
(defun my-orb-latex-note-to-org (citekey)
(let* ((entry (bibtex-completion-get-entry citekey))
(note (bibtex-completion-apa-get-value "note" entry ""))
(pandoc-command "pandoc --from latex --to org")
result)
(with-temp-buffer
(shell-command (format "echo \"%s\" | %s" note pandoc-command)
(current-buffer))
(setq result (buffer-substring-no-properties (point-min) (point-max))))))
(setq orb-preformat-keywords '("citekey" "author" "date" "note" "booktitle" "title" "=key=" "url" "file" "keywords" "author-or-editor"))
(setq org-roam-capture-templates
'(
("d" "default" plain "%?"
:target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
:unnarrowed t)
("b" "bibliography reference" plain "#+filetags ::
#+keywords :: %^{keywords}
#+author(s) :: %^{author-or-editor}\n\n
%?"
:target
(file+head "references/${citekey}.org" "#+title: ${title}\n")
:unnarrowed t)
("r" "bibliography reference with raw zotero note" plain "#+filetags ::
#+keywords :: %^{keywords}
#+author(s) :: %^{author-or-editor}\n\n
\n* Notes (from zotero)\n\n
%^{note} %?"
:target
(file+head "references/${citekey}.org" "#+title: ${title}\n")
:unnarrowed t)
("z" "bibliography reference with zotero note" plain "#+filetags ::
#+keywords :: %^{keywords}
#+author(s) :: %^{author-or-editor}\n\n
\n* Notes (from zotero)\n\n
%(my-orb-latex-note-to-org \"${citekey}\") %?"
:target
(file+head "references/${citekey}.org" "#+title: ${title}\n")
:unnarrowed t)))
Nearly every attempt resulted in a pandoc error like the following:
Error at (line 2, column 2):
unexpected end of input
expecting \end{itemize}
^
So it seems like the bibtex file may have some formatting errors. Which is strange because it is automatically generated by better biblatex in zotero.
In any case, I tried to create a new note in zotero, that updated my bib file, and when I ran the above code on the new note it worked fine and formatted the notes correctly for an org file.
I am not sure what the issue is here. But having run the same file that gave me the error above through the capture I defined above under the binding “r” that returned just the expansion of %^{note}
I noticed that the latex string it produced was missing a curly bracket at the end. So the last line was like this: \end{itemize
Having spent some time looking through the orb .el file, it looks like the pre-expansion is handled by the same function: bibtex-completion-get-value
I am assuming that for whatever reason, this function is too eagerly cutting brackets when parsing the bibtex file. The bibtex entry that was giving me this error is the following:
@incollection{alstonEpistemicDisederataApproach2005,
title = {3. {{The Epistemic Disederata Approach}}},
booktitle = {Beyond "{{Justification}}": {{Dimensions}} of {{Epistemic Evaluation}}},
author = {Alston, William P.},
date = {2005},
pages = {39--57},
publisher = {{Ithaca: Cornell University Press}},
keywords = {\#Noted,pluralism about justification},
note = {\section{Beyond Justification (Alston 2005)}
\subsection{3. The Epistemic Disederata Approach (pp. 39-57)}
\par
\begin{itemize}
\item We can split positive epistemic disederata across broad categories of truth-conduciveness (adequacy, reliability etc), discriminatory aids (evidence, well-grounded belief etc), deontological categories (responsible belief), and cognitive goals (understanding, coherence etc)
\item Which of these standards is more important will be dynamically updated depending on the context
\item Some will always be more core or fundamental than others (namely the truth-conducive group)
\item But this justifies a general pluralism about epistemic disederata -- there are many and they are relatively important depending on what we think
\item For instance, once this approach is adopted the disputes around Norman dissipate -- under some disederata he is in a positive position (reliability etc) and others he is not -- the further question of whether he is justified is just not a live question anymore -- we can drop the word justification altogether
\end{itemize}
\par
\begin{itemize}
\item Claims that cognitive goals like understanding are not related to aim for truth directly but what is it to understand something except to gather contextual truths about it?
\item Is the issue of Norman genuinely resolved or just pushed back a step -- everyone already knows that different theorists apply different standards of positive epistemic status to Norman, this is not news, but the dispute remains live, because there are other questions where justification doesn't even come up like -- is it legitimate for Norman to travel to New York to see the president on the basis of his clairvoyant (true) belief that she is in that city -- this will bring back all the same issues and we didn't even have to use the word justification
\end{itemize}}
}