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

Extension does not find some .bib files specified as relative paths in subfolders when bibliography is specified without square brackets #49

Open
paulenit opened this issue Jan 9, 2024 · 2 comments

Comments

@paulenit
Copy link

paulenit commented Jan 9, 2024

While investigating why the PandocCiter extension did not show any suggestions for the .bib file referenced in my YAML header I found the following IMO incorrect behavior:

Problem description

PandocCiter does not find my .bib file and provide suggestions if it is

  • saved at the root of the directory currently open in VSCode ("project") and
  • referenced by a relative path from a Markdown file in a subfolder of the project (e.g. ../bibliography.bib)

It appears PandocCiter resolves the relative path to the .bib file from the project root instead of the Markdown file that references it in the YAML header.

Expected behavior

PandocCiter should search for the referenced .bib file relative to the file in which it is referenced and not from the project root.

Steps to reproduce

I made a minimal sample project to test this with: pandoc-citer-example.zip

  1. Unpack the zip so that you have a pandoc-citer-example folder with the subfolders draft and final, as well as the bibliography.bib file.
  2. Open the folder pandoc-citer-example in VSCode
  3. Open the document final/report.md with the PandocCiter extension installed and activated with default settings.
  4. Start typing [@ anywhere in the document.
  5. No citation keys are suggested :(

Additional Details

In my use case, I have a project folder for a seminar and subfolders with different Markdown documents (e.g. lecture notes, final report, etc.). I save a .bib (BibTeX, not BibLaTeX to be specific) at the project root so that I can cite the sources from this one file from all Markdown documents. I reference this file in the subfolders containing the Markdown documents in the Pandoc Markdown YAML header as bibliography: "bibliography.bib".

The PandocCiter output shows that the extension searches for a file one level above the root project (and does not find it), which leads me to believe the extension searches relative to the project root.

A workaround is to define (e.g. in the VSCode's project settings) a Default Bib file (e.g. './bibliography.bib'). However, this works only for one .bib file and is tedious to define for every project when the path is already specified in the Markdown documents YAML header.

Another "workaround" is to enclose the .bib path in square brackets: bibliography: ["../bibliography.bib"] as suggested in #5.

This seems very related to #32. Maybe what I experience is a side effect of the change mentioned in that issue? Fixing my problem by simply adding the square brackets seems like an easy fix and all examples in the README use these brackets. However, I think Pandoc allows bibliography paths without these brackets and #32 makes it seem like they should also be optional for this extension. If this is intended, IMO documentation should be added to make clear that adding square brackets makes the path relative to the document while no brackets make it relative to the project, as this is how it appears currently...

Install details:
Version: 1.85.1
Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2
Date: 2023-12-13T09:47:11.635Z
Electron: 25.9.7
ElectronBuildId: 25551756
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Linux x64 6.6.9-arch1-1

My OS is Arch Linux and PandocCiter is at version v.0.10.3.

Anyways, thanks for the great extension, fixing one of the most annoying holes in my markdown writing pipeline <3

@notZaki
Copy link
Owner

notZaki commented Jan 10, 2024

Thanks for the thorough investigation and for identifying the problem. Indeed, relative paths were incorrectly using the project root instead of the active document's path. That also explains the issues that were reported in the past.

I've tried to fix this in the latest release (0.10.4). Hopefully that works.

@splithor1zon
Copy link

I recommend to mention the fact that if user is currently using the project-relative path, they have to change to the file-relative path. My citations stopped working after the latest update, I had to check this issue to find out what changed. Would you please mention the potential neccessity of changing bibliography paths to file-relative in the changelog? Thank you!

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

3 participants