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

Pandoc: error reading bibliography file, unexpected J #2826

Closed
samprovost opened this issue Apr 5, 2024 · 9 comments
Closed

Pandoc: error reading bibliography file, unexpected J #2826

samprovost opened this issue Apr 5, 2024 · 9 comments
Labels

Comments

@samprovost
Copy link

samprovost commented Apr 5, 2024

Debug log ID

I3J5I8HT-refs-euc/6.7.173-6

What happened?

When using pandoc to create a docx file from a note in Obsidian I get the following error:

Error reading bibliography file /Users/samprovost/Documents/Obsidian Vaults/Obsidian Vault/My Library.bib:
(line 2849, column 13):
unexpected 'J'

The bibliography entry that pandoc is having trouble with is:

@article{de Jong2012,
  title = {Perceived Green Qualities Were Associated with Neighborhood Satisfaction, Physical Activity, and General Health: Results from a Cross-Sectional Study in Suburban and Rural {{Scania}}, Southern {{Sweden}}},
  author = {family=Jong, given=K., prefix=de, useprefix=true and Albin, M. and Skärbäck, E. and Grahn, P. and Björk, J.},
  date = {2012},
  journaltitle = {Health Place},
  volume = {18},
  doi = {10.1016/j.healthplace.2012.07.001}

It appears the issue is with the author name "de Jong". The J in Jong is (line 2849, column 13).

I am using pandoc version -3.1.12.3-arm64-macOS on an Apple Silicon M1 Max.

Thanks
Sam

@retorquere
Copy link
Owner

retorquere commented Apr 5, 2024

The entry as pasted above is incomplete (missing ending brace), so that could explain the problem, there's also a space in your citation key, which isn't valid. Other than that I would guess that maybe Pandoc doesn't understand extended name format, because this renders without issue:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}% see: http://tex.stackexchange.com/q/71517/8528
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage[style=apa, backend=biber]{biblatex}
\usepackage{hyperref}

\DeclareLanguageMapping{british}{british-apa}

\begin{filecontents}{\jobname.bib}
@article{deJong2012,
  title = {Perceived Green Qualities Were Associated with Neighborhood Satisfaction, Physical Activity, and General Health: Results from a Cross-Sectional Study in Suburban and Rural {{Scania}}, Southern {{Sweden}}},
  author = {family=Jong, given=K., prefix=de, useprefix=true and Albin, M. and Skärbäck, E. and Grahn, P. and Björk, J.},
  date = {2012},
  journaltitle = {Health Place},
  volume = {18},
  doi = {10.1016/j.healthplace.2012.07.001}
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

\nocite{*}

\printbibliography
\end{document}

but you can turn off extended name format for biblatex in the preferences.

@njbart
Copy link
Contributor

njbart commented Apr 6, 2024

FWIW, pandoc does support the biblatex extended name format. (Not documented in the pandoc manual, apparently, but see the source.)

@retorquere
Copy link
Owner

If I put this into bib.bib:

@article{deJong2012,
  title = {Perceived Green Qualities Were Associated with Neighborhood Satisfaction, Physical Activity, and General Health: Results from a Cross-Sectional Study in Suburban and Rural {{Scania}}, Southern {{Sweden}}},
  author = {family=Jong, given=K., prefix=de, useprefix=true and Albin, M. and Skärbäck, E. and Grahn, P. and Björk, J.},
  date = {2012},
  journaltitle = {Health Place},
  volume = {18},
  doi = {10.1016/j.healthplace.2012.07.001}
}

and run

pandoc bib.bib -t csljson -o bib.json

pandoc converts the entry to CSL-JSON successfully.

Ah, I get it; if I enter the input you originally posted (with the missing end brace and the space in the citation key), pandoc reports:

Error at "bib.bib" (line 1, column 13):
unexpected 'J'
@article{de Jong2012,

so it's the space in the key. pandoc is quite precise in this case where the error is. BBT doesn't generate keys with spaces, but it will blindly accept whatever key you put into the extra field. BBT can put keys in the extra field on your behalf, but when doing that, it cannot generate keys with spaces, so this key was put there manually, or it was put there by BBT and then edited.

@samprovost
Copy link
Author

samprovost commented Apr 7, 2024 via email

@retorquere
Copy link
Owner

Is the issue resolved?

@samprovost
Copy link
Author

Hello,

The issue is resolved. It looks like BBT added spaces to the citekey of some of the documents in my Zotero library with extended names.

I didn't edit any of them or add spaces in the extra field so I'm not sure how they ended up there if, as you say, BBT can't add keys.

Anyway I just had to run the pandoc script a few times to find the entries with spaces and remove them in Zotero.

Thanks for your help

Sam

@retorquere
Copy link
Owner

Hello,

The issue is resolved. It looks like BBT added spaces to the citekey of some of the documents in my Zotero library with extended names.

BBT always removes spaces in the last step of key generation. The name (title?) cannot affect that. If you can replicate bbt generating spaces I'd like to know.

@samprovost
Copy link
Author

samprovost commented Apr 10, 2024 via email

@retorquere
Copy link
Owner

The key generation has no relation to the extended name formats - both take the zotero author name (first/last or single part) and generate content (keys or extended names respectively). I don't first generate the extended name and then generate a key from it. But even if I would have, spaces are unconditionally removed from the key at the end of the key generation process.

@retorquere retorquere closed this as not planned Won't fix, can't repro, duplicate, stale Apr 13, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants