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

Templates render unwanted HTML #208

Closed dr-cs closed 1 year ago

dr-cs commented 1 year ago

Describe the bug

If you put certain characters in BibLaTeX entries and use those entries in a template, they are rendered as HTML elements.

To Reproduce

Minimum working example:

  1. Add this to your BibLaTeX database:
@book{underscoretest,
  title={Snake_Case}
}
  1. In your Citations settings in Obsidian, set your Literature note title template to {{title}} and your Literature note content template to
{{title}}
  1. Create a new literature note for "Snake_Case".

Expected behavior

A new note with template entries as they appear in the BibLaTeX database, not rendered to HTML.

Actual behavior

A note is created with the title Snake_sub_c__sub_ase.md and contents:

Snake<sub>c</sub>ase

Using HTML escaping, {{{title}}}, doesn't help.

Screenshots

This HTML rendering also appears in the new note autocomplete list.

image

Note in Obsidian's default view:

image

Platform

Additional context

Perhaps the Handlebars library is being "helpful" by assuming you mean to create subscripts with _ as in LaTeX math (and I assume other cases, like superscripting with ^ but I haven't tested other cases).

In the case of the file name, the plugin is translating the angle brackets and forward slash (which are disallowed in file names) into underscores.

dr-cs commented 1 year ago

Duh. Just figured it out. Escape underscores with \, e.g., Snake\_Case in the BibLaTeX file. It's been a while since I've written academic papers, so my LaTeX is rusty. Should have been my first thought.