Version 6.0 no longer works with JabRef_LibreOffice_Converter
I just tried the version 6.0 alpha 3 since I wanted to benefit from the support of CSL styles for LibreOffice. My publisher request APA 7...
But I am also using citekeys within the XML documents produced by another piece of software (Scrivener) and I was thus so far relying on the nice little LibreOffice plugin JabRef_LibreOffice_Converter from @teertinker which allows to turn \cite{citationkey} in the XML document opened in LibreOffice into an active citation that JabRef understands.
With version JabRef 6.0, this no longer works (the active citations created by the plugin are not recognised by JabRef). Perhaps this is just some glitch connected to the alpha stage of 6.0, or perhaps there is something to change in JabRef_LibreOffice_Converter.
In any case, I wanted to flag this possibly new incompatibility.
Link to the tool: https://github.com/teertinker/JabRef_LibreOffice_Converter
Howto: https://github.com/teertinker/JabRef_LibreOffice_Converter#what-it-does
Solution sketch: The issue (in all probability) arises due to the disparity in reference mark formats across the (old) JStyles and the (new) CSL styles. CSL styles use the following format: https://github.com/JabRef/jabref/blob/9768ab390e04349d97d782e8e04cb707367afb1f/jablib/src/main/java/org/jabref/logic/openoffice/ReferenceMark.java#L18-L24
Whereas JStyle uses: https://github.com/JabRef/jabref/blob/9768ab390e04349d97d782e8e04cb707367afb1f/jablib/src/main/java/org/jabref/logic/openoffice/backend/Codec52.java#L21-L25
The rationale behind which is: https://github.com/JabRef/jabref/blob/9768ab390e04349d97d782e8e04cb707367afb1f/docs/code-howtos/openoffice/overview.md?plain=1#L189-L196
So the first step would be to confirm that this is the cause of the problem. This can either be done by testing if the JStyle citations still work with the LO converter properly (a beginner guide to use the LO integration in JabRef is available here for newcomers, and the LO converter extension has a self-explanatory readme here). The stricter/ideal confirmation can be going through the code of the converter, and seeing that it indeed is made to parse reference marks of the JStyle format.
If that is indeed the case, the next step (and thus, the solution) would be to change the format of CSL reference marks to that of JStyles. All the logic on how the different parameters are populated are available in org.jabref.logic.openoffice.backend.Codec52.java. Similar logic should be incorporated for all parameters 1:1 for CSL styles in its respective class ReferenceMark.java. Documentation on the parameters are available at https://devdocs.jabref.org/code-howtos/openoffice/overview.html#what-is-stored-in-a-document-jabref52.
Note that one has to be familiar with all three kinds of citation types available via these three buttons in the LO panel:
The final step would be to adapt the parsing and replacement logic in org.jabref.logic.openoffice.oocsltext.CSLReferenceMark.java and org.jabref.logic.openoffice.oocsltext#CSLReferenceMarkManager.java, especially methods readAndUpdateExistingMarks, getUpdatedReferenceMarkNameWithNewNumbers, updateAllCitationNumbers, getUpdatedCitationTextWithNewNumbers and updateMarkAndTextWithNewNumbers to ensure that the number replacement functionality works properly for numeric styles if a citation is moved with respect to another or deleted in the document. Once done, this can be verified via some relatively easy manual testing.
Some more hints - for an example, see how conversion/mapping logic for {citationType} is present for JStyles:
https://github.com/JabRef/jabref/blob/9768ab390e04349d97d782e8e04cb707367afb1f/jablib/src/main/java/org/jabref/logic/openoffice/backend/Codec52.java#L54-L79
Think of how this can be reused. We get the citation type for any citation style at the entry point from: https://github.com/JabRef/jabref/blob/9768ab390e04349d97d782e8e04cb707367afb1f/jabgui/src/main/java/org/jabref/gui/openoffice/OOBibBase.java#L543-L549
(the CitationType citationType parameter here).
Similarly, extend/map all the logic to CSL for {number} and {citationKeys} (which are simpler than {citationType}).
This issue (partially) refs. https://github.com/JabRef/jabref/issues/11829 as well.
Confirmed: The issue arises due to the reasons stated above. https://github.com/teertinker/JabRef_LibreOffice_Converter/blob/747dcce9c9761d203f321c9949796f6b059c37da/JabRefConverterLib/Module1.xba#L38-L52
Alternative: We fork https://github.com/teertinker/JabRef_LibreOffice_Converter and add support for our current CSL Reference mark format. https://github.com/JabRef/jabref/labels/good%20first%20issue
Hey @courtiol You can try using the modified extension: https://github.com/JabRef/JabRef_LibreOffice_Converter
Many thanks, I will try ASAP and report to you if something does not seem quite right. I really appreciate the effort @subhramit !
hi @subhramit, I have now tested your forked add-in and it still does not fully work.
The references get inserted but the citekeys, here "\cite{Einstein1935}" do not get replaced by text "Einstein, 1935" (or similar):
Here is a reprex:
-
- I exported ref from [https://journals.aps.org/pr/abstract/10.1103/PhysRev.47.777](https://journals.aps.org/pr/abstract/10.1103/PhysRev.47.777%5C) into a bibtex file. It contains the following BibTeX entry:
@article{PhysRev.47.777, title = {Can Quantum-Mechanical Description of Physical Reality Be Considered Complete?}, author = {Einstein, A. and Podolsky, B. and Rosen, N.}, journal = {Phys. Rev.}, volume = {47}, issue = {10}, pages = {777--780}, numpages = {0}, year = {1935}, month = {May}, publisher = {American Physical Society}, doi = {10.1103/PhysRev.47.777}, url = {https://link.aps.org/doi/10.1103/PhysRev.47.777} }
-
- In JabRef, I imported the citation into a new library (File -> Import -> Import into current library) The citation keys became: "Einstein1935" (without quotes)
-
- I save the new library as test.bib
-
- I opened a new Writer Document into libreOffice
-
- I wrote inside that document: "I want to cite this paper \cite{Einstein1935}." (without quotes)
-
- In libreOffice, I clicked on the add-in, I selected CSL and clicked on the Convert button below "\cite{bibtexkey} -> JabRef ..."
-
- In JabRef I clicked on the Connect button and the document got detected
-
- In JabRef, I selected the style APA 7th edition and clicked on Make/Sync bibliography
Many thanks for looking into it.
Could you try the refresh button in the libreoffice plugin in JabRef after VII?
Could you try the refresh button in the libreoffice plugin in JabRef after VII?
Yes, although that's now mapped to "refresh bibliography" which won't refresh citations.
Can you, instead, cite something (even the same entry works) and then delete it? It should refresh the existing citations.
@teertinker, I don't see any refresh button in the libreOffice app. @subhramit, if I cite something via JabRef, that new reference get formatted but it does not impact the other ones. So I don't think this works unfortunately...
@subhramit, if I cite something via JabRef, that new reference get formatted but it does not impact the other ones. So I don't think this works unfortunately...
Can you hover over the reference mark (the grey box which encloses the citation in your screenshot above) and provide a picture of its contents?
It says for e.g.: "Reference: JABREF_Einstein1935 CID_100 cite"
It says for e.g.: "Reference: JABREF_Einstein1935 CID_100 cite"
Okay. It is a bit difficult to explain why the issue is happening, I will write a text here once I find some more time. But the (current) workaround would be:
In JabRef, I imported the citation into a new library (File -> Import -> Import into current library) The citation keys became: "Einstein1935" (without quotes) I save the new library as test.bib I opened a new Writer Document into libreOffice I wrote inside that document: "I want to cite this paper \cite{Einstein1935}." (without quotes) In libreOffice, I clicked on the add-in, I selected CSL and clicked on the Convert button below "\cite{bibtexkey} -> JabRef ..." In JabRef I clicked on the Connect button and the document got detected In JabRef, I selected the style APA 7th edition and clicked on Make/Sync bibliography
Once you are done converting all the citations ("\cite{bibtexkey} -> JabRef ..."), that is, after the second-last step (once the document gets detected), insert any dummy citation (can even be the same entry) in some style (which you don't want, in this case anything that is not APA 7th...) to the document, and then change the style to the one you want (APA 7th), and insert dummy-citation again - now all citations would have refreshed. Something like this:
You can now delete the two dummy citations.
Again, this may be a bit inconvenient, but some conscious decisions were taken not keeping the LO extension in mind when developing the CSL integration. Thanks for pointing this out, we will try to find a more convenient way to get the refresh done.