hans / obsidian-citation-plugin

Obsidian plugin which integrates your academic reference manager with the Obsidian editor. Search your references from within Obsidian and automatically create and reference literature notes for papers and books.
MIT License
1.04k stars 77 forks source link

Citation import fields with escape #202

Closed Seraphli closed 1 year ago

Seraphli commented 1 year ago

Describe the bug I have this template.

---
authors: {{authorString}}
year: {{year}}
url: {{URL}}
annotation-target: {{{entry.data.fields.filename}}}
---
Title: {{title}}
Abstract: {{abstract}}

The filename is produced by Zotero, with the following postscript. https://github.com/retorquere/zotero-better-bibtex/discussions/2311 The filename is correct in the bib file. image But After I try to create a new note with the template. Here is what I get. image So how to fix this? I want this field to be the same as it is in the bib file.

To Reproduce Steps to reproduce the behavior:

  1. Set postscript in Zotero, and export library.
  2. Create new note with the template.
  3. See error

Expected behavior

annotation-target: Pan et al_2022_Iso-Dream - Isolating Noncontrollable Visual Dynamics in World Models.pdf

Screenshots As above.

Platform

Seraphli commented 1 year ago

This issue is related to the toJSON function I think. Because when I change the postscript to replace the eprint key instead of creating a new key, the template works fine. I choose the eprint key because the data type defined in the abstract class is a string. I think all string type keys will work, if they are pre-defined in the abstract class. Other keys will be added by the toJSON function, which causes this problem.

dr-cs commented 1 year ago

Try escaping the underscore in your bibliography database (e.g., .bib file) with \. _ is used for subscripts in LaTeX, so I think the .bib parser is adding the <sub></sub> elements. I ran into the same issue: Issue #208 .

Seraphli commented 1 year ago

@dr-cs I used another way to escape this issue.