Open andersonjwan opened 1 year ago
I'd like to request this as well. I have many papers, and I'd like to add a bibTeX entry section to my template so I can quickly copy-paste it from the markdown document.
## BibTeX Entry
` ``
{{raw}}
` ``
which would produce this when I open a document
@misc{https://doi.org/10.48550/arxiv.2301.13188,
doi = {10.48550/ARXIV.2301.13188},
url = {https://arxiv.org/abs/2301.13188},
author = {Carlini, Nicholas and Hayes, Jamie and Nasr, Milad and Jagielski, Matthew and Sehwag, Vikash and Tramèr, Florian and Balle, Borja and Ippolito, Daphne and Wallace, Eric},
keywords = {Cryptography and Security (cs.CR), Computer Vision and Pattern Recognition (cs.CV), Machine Learning (cs.LG), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {Extracting Training Data from Diffusion Models},
publisher = {arXiv},
year = {2023},
copyright = {arXiv.org perpetual, non-exclusive license}
}
@GrahamBenHarper I did some work myself to get this functional using the {{entry}}
variable from the documentation of the EntryBibLaTeXAdapter
found here. From this, the following template will work to generate the {{raw}}
portion of the BibTeX we are looking for:
```bibtex
@{{entry.data.type}}{ {{~citekey}}
{{#each entry.data.fields}}
{{ @key }}={ {{~this~}} },
{{/each}}
}
Note: The order of the keys is not consistent with the original string (this is not possible as it is a dictionary which is an unordered set). However, BibTeX processing engines also do not care about order, so this is more of a pedantic issue. For those that use `CSL-JSON`, you may have to modify this to work with the `EntryCSLAdapter`.
```bibtex @{{entry.data.type}}{ {{~citekey}} {{#each entry.data.fields}} {{ @key }}={ {{~this~}} }, {{/each}} }
Actually, no. This does not work for all fields as in the case of the author
having more than one author, the resulting string looks like:
Family, First,Family, First,Family, First
whereas we would expect it to be:
Family, First and Family, First and Family, First
Therefore, this solution is not complete, so the need for a {{raw}}
variable is still quite relevant, unfortunately.
Thanks for looking at this @andersonjwan. I suspect we might be able to add another field to the EntryData
object and initialize it with the raw string in the loadEntries
routine since the raw entry is an argument for the function, but I'm not certain (relevant line linked below).
https://github.com/hans/obsidian-citation-plugin/blob/master/src/types.ts#L80-L83
I'll have to play around and see if I can get something working.
Is your feature request related to a problem? Please describe. No.
Describe the solution you'd like It would be nice to have the ability to access the source string where an
Entry
was built upon for several reasons: (1) if I am using these citations to store information, then I would like to quickly access/display this information to be used in other sources/sharing, and (2) filtering the contents of the fields to re-create the source is a cumbersome.This could be supported with an additional handler variable such as
{{raw}}
.Describe alternatives you've considered The alternative would be to use handlers or js to effectively re-create the source string by checking for the existence of fields and their associated values. However, this is not so friendly for those wanting to view the BibLaTeX entry within Obsidian.
Additional context None.