jabref icon indicating copy to clipboard operation
jabref copied to clipboard

Rework LibreOffice CSL Style Inference flow

Open pluto-han opened this issue 3 months ago • 41 comments

We implemented compatibility with Zotero and add a preference "Infer CSL style from document". But this preference causes many issues when doing interoperability work with Zotero users.

Goals of rework:

  • [ ] Decouple from Zotero flow - Allow "infer style" for JabRef-only flows as well
  • [ ] Decouple trigger from "other" LO functions like connect, cite etc - Remove "Infer CSL style from document" from preference. Instead, add it as a dedicated button
  • [ ] Show notifications of detected style used in the document

Hints:

  • Button shouldn't be greyed out in jabref mode
  • Reuse the code for the button "cite"

Refs https://github.com/JabRef/jabref/pull/16461 https://github.com/JabRef/jabref/pull/16358

pluto-han avatar Aug 20 '26 20:08 pluto-han

/assign-me

fulluhere avatar Aug 21 '26 12:08 fulluhere

Thank you for your continued work in JabRef. At this point, you probably already know the basics and the important links. If not, our contributing guidelines is the place you should go to.

At this point in time, you raised 1 pull request(s) of which 0% (0/1) have been merged.

jabref-machine avatar Aug 21 '26 12:08 jabref-machine

Hi @pluto-han @subhramit , I’d be interested in working on this issue. I noticed that @fulluhere is currently assigned to it. If they’re no longer working on it or the assignment is available again, I’d be happy to take it up. Please let me know. Thanks!

hello-ryuzaki avatar Aug 23 '26 18:08 hello-ryuzaki

Hey @hello-ryuzaki , you'll get a notification in case they abandon the issue. We usually have a limit for time and a bar for quality, so if either isn't met, issues are freed up again.

subhramit avatar Aug 23 '26 19:08 subhramit

⏰ Assignment Reminder

Hi @fulluhere, this is a friendly reminder about your assignment to this issue.

[!WARNING] This issue will be automatically unassigned in 4 days if there's no activity.

Remember that you can ask the JabRef Guru or DeepWiki about anything regarding JabRef. Additionally, our contributing guide has hints on creating a pull request and a link to our Gitter chat.

How to keep your assignment


If you are working on it, you can prevent automatic unassignment by:

  • Submitting a draft pull request with your progress within 4 days
  • Asking for the 📌 Pinned label if you need more time

We appreciate your contribution and are here to help if needed!

github-actions[bot] avatar Aug 27 '26 15:08 github-actions[bot]

@fulluhere are you still working on this? Please unassign yourself if you are not.

subhramit avatar Aug 28 '26 16:08 subhramit

@subhramit there is no any activity can you assign this to me

thesauravpoddar avatar Sep 02 '26 03:09 thesauravpoddar

This requires familiarity with multiple software (Zotero, LibreOffice) and context of our LibreOffice integration. This issue will be hard for you unless you already have context and reproduced the current state of the features. I would ask you to go for something else, someone from the internal team may take this up.

subhramit avatar Sep 02 '26 07:09 subhramit

This requires familiarity with multiple software (Zotero, LibreOffice) and context of our LibreOffice integration. This issue will be hard for you unless you already have context and reproduced the current state of the features. I would ask you to go for something else, someone from the internal team may take this up.

Still i want to give it a try, will learn all required things just give refrence of some things that i should know or i should look at

thesauravpoddar avatar Sep 02 '26 07:09 thesauravpoddar

Do something, since your earlier contributions were not exactly clean and at times we had to repeat information that was already present, try the inference flow out and tell me in your own words what you understand about what needs to be done, and then code snippet wise what your approach will be. If you understand it correctly, we can move forward.

We don't have time to guide these days, because a release is due. We expect contributors to help us, not take our time away. Except for a little bit of leeway for first time contributors/good first issues in that regard.

subhramit avatar Sep 02 '26 08:09 subhramit

Do something, since your earlier contributions were not exactly clean and at times we had to repeat information that was already present, try the inference flow out and tell me in your own words what you understand about what needs to be done, and then code snippet wise what your approach will be. If you understand it correctly, we can move forward.

We don't have time to guide these days, because a release is due. We expect contributors to help us, not take our time away. Except for a little bit of leeway for first time contributors/good first issues in that regard.

Okay understood and repeataton of things won't happen again

thesauravpoddar avatar Sep 02 '26 08:09 thesauravpoddar

So this is what i understood is

private static Optional<String> readSerializedData(XTextDocument document)
            throws WrappedTargetException {
        Optional<String> serializedData = readChunkedProperty(document, ZOTERO_PREF);
        if (serializedData.isEmpty()) {
            serializedData = readChunkedProperty(document, CSL_PREF);
        }
        return serializedData;
    }

so readSerializedData tries both ZOTERO_PREF and CSL_PREF in which ZOTERO_PREF is zotero specifc so when it is absent in meta.xml file it falls back to CSL_PREF that is for jabref only correct me if i am wrong and for meta.xml jabref never parses it itslef but through libreoffice over its api XTextDocumet reading and writing user-defined document properties on the open document object and LibreOffice itself later serializes those properties into meta.xml so it means since when ZOTERO_PREF not present it goes to CSL_PRED half way decoupling is done as findCitationStyle is getting style id from XTextDocument document and checks it over the availableStyles for i guess i have to do the same i have to do the same One thing that i uncerstood is weiteCitationStylke is also writes ZOTERO_PREF

    private static Optional<String> readSerializedData(XTextDocument document)
            throws WrappedTargetException {
        Optional<String> serializedData = readChunkedProperty(document, ZOTERO_PREF);
        if (serializedData.isEmpty()) {
            serializedData = readChunkedProperty(document, CSL_PREF);
        }
        return serializedData;
    }

so readSerializedData is done for both ZOTERO_PREF and CSL_PREF but when it writes it never writes CSL_PREF so even if readSerializedData reads a non zotero document that is jabref writeCitationStyle writes ZOTERO_PREF there only so whatever i understood in zotero mode when inference calls findCitationStyle so it sees ZOTERO_PREF and it works this is what i understood so far i have not thoght anything about my approach yet codewise what i will do that i will tell you

thesauravpoddar avatar Sep 03 '26 14:09 thesauravpoddar

it falls back to CSL_PREF that is for jabref only

CSL_PREF is the old name for ZOTERO_PREF. I add it just in case users use old version of Zotero.

Please also clone Zotero's repo and look into it. You can also follow the steps in the video in https://github.com/JabRef/jabref/pull/16358 and the gifs in https://github.com/JabRef/jabref/wiki/GSoC-2026-%E2%80%90-Improved-LibreOffice%E2%80%90JabRef-integration

pluto-han avatar Sep 03 '26 14:09 pluto-han

it falls back to CSL_PREF that is for jabref only

CSL_PREF is the old name for ZOTERO_PREF. I add it just in case users use old version of Zotero.

Please also clone Zotero's repo and look into it. You can also follow the steps in the video in #16358 and the gifs in https://github.com/JabRef/jabref/wiki/GSoC-2026-%E2%80%90-Improved-LibreOffice%E2%80%90JabRef-integration

Okay understood thanks for clearifying

thesauravpoddar avatar Sep 03 '26 14:09 thesauravpoddar

/assign @thesauravpoddar

subhramit avatar Sep 03 '26 17:09 subhramit

Thanks for guiding @pluto-han

subhramit avatar Sep 03 '26 17:09 subhramit

Thank you for your continued work in JabRef. At this point, you probably already know the basics and the important links. If not, our contributing guidelines is the place you should go to.

At this point in time, you raised 4 pull request(s) of which 100% (4/4) have been merged.

jabref-machine avatar Sep 03 '26 17:09 jabref-machine

So this is what i understood is

private static Optional readSerializedData(XTextDocument document) throws WrappedTargetException { Optional serializedData = readChunkedProperty(document, ZOTERO_PREF); if (serializedData.isEmpty()) { serializedData = readChunkedProperty(document, CSL_PREF); } return serializedData; } so readSerializedData tries both ZOTERO_PREF and CSL_PREF in which ZOTERO_PREF is zotero specifc so when it is absent in meta.xml file it falls back to CSL_PREF that is for jabref only correct me if i am wrong and for meta.xml jabref never parses it itslef but through libreoffice over its api XTextDocumet reading and writing user-defined document properties on the open document object and LibreOffice itself later serializes those properties into meta.xml so it means since when ZOTERO_PREF not present it goes to CSL_PRED half way decoupling is done as findCitationStyle is getting style id from XTextDocument document and checks it over the availableStyles for i guess i have to do the same i have to do the same One thing that i uncerstood is weiteCitationStylke is also writes ZOTERO_PREF

private static Optional<String> readSerializedData(XTextDocument document)
        throws WrappedTargetException {
    Optional<String> serializedData = readChunkedProperty(document, ZOTERO_PREF);
    if (serializedData.isEmpty()) {
        serializedData = readChunkedProperty(document, CSL_PREF);
    }
    return serializedData;
}

so readSerializedData is done for both ZOTERO_PREF and CSL_PREF but when it writes it never writes CSL_PREF so even if readSerializedData reads a non zotero document that is jabref writeCitationStyle writes ZOTERO_PREF there only so whatever i understood in zotero mode when inference calls findCitationStyle so it sees ZOTERO_PREF and it works this is what i understood so far i have not thoght anything about my approach yet codewise what i will do that i will tell you

  1. Currently style is written to meta.xml only for Zotero mode
  2. We want to make it independent of the Zotero mode, it should always write
  3. Reading already happens for Zotero mode (if infer is enabled). We want to allow that mode for reading it and setting the style in JabRef mode as well.
  4. UI: The button is greyed out in JabRef mode. It should always be available to opt in after this.

subhramit avatar Sep 03 '26 17:09 subhramit

try the inference flow out and tell me in your own words what you understand about what needs to be done

I don't think you tried this - did you?

and then code snippet wise what your approach will be. If you understand it correctly, we can move forward.

Seems like you directly started looking at the code. I mentioned "and then". There was a reason behind that order, to build understanding. Reading code first before understanding the feature doesn't really make one understand anything. I don't understand why you find it hard to follow instructions. Please try out, and ask whatever you feel you are a bit unclear about.

subhramit avatar Sep 03 '26 18:09 subhramit

So this is what i understood is private static Optional readSerializedData(XTextDocument document) throws WrappedTargetException { Optional serializedData = readChunkedProperty(document, ZOTERO_PREF); if (serializedData.isEmpty()) { serializedData = readChunkedProperty(document, CSL_PREF); } return serializedData; } so readSerializedData tries both ZOTERO_PREF and CSL_PREF in which ZOTERO_PREF is zotero specifc so when it is absent in meta.xml file it falls back to CSL_PREF that is for jabref only correct me if i am wrong and for meta.xml jabref never parses it itslef but through libreoffice over its api XTextDocumet reading and writing user-defined document properties on the open document object and LibreOffice itself later serializes those properties into meta.xml so it means since when ZOTERO_PREF not present it goes to CSL_PRED half way decoupling is done as findCitationStyle is getting style id from XTextDocument document and checks it over the availableStyles for i guess i have to do the same i have to do the same One thing that i uncerstood is weiteCitationStylke is also writes ZOTERO_PREF

private static Optional<String> readSerializedData(XTextDocument document)
        throws WrappedTargetException {
    Optional<String> serializedData = readChunkedProperty(document, ZOTERO_PREF);
    if (serializedData.isEmpty()) {
        serializedData = readChunkedProperty(document, CSL_PREF);
    }
    return serializedData;
}

so readSerializedData is done for both ZOTERO_PREF and CSL_PREF but when it writes it never writes CSL_PREF so even if readSerializedData reads a non zotero document that is jabref writeCitationStyle writes ZOTERO_PREF there only so whatever i understood in zotero mode when inference calls findCitationStyle so it sees ZOTERO_PREF and it works this is what i understood so far i have not thoght anything about my approach yet codewise what i will do that i will tell you

  1. Currently style is written to meta.xml only for Zotero mode
  2. We want to make it independent of the Zotero mode, it should always write
  3. Reading already happens for Zotero mode (if infer is enabled). We want to allow that mode for reading it and setting the style in JabRef mode as well.
  4. UI: The button is greyed out in JabRef mode. It should always be available to opt in after this.

sorry for my poor explanationa and vague wordings wanted to explain the same thing

thesauravpoddar avatar Sep 04 '26 09:09 thesauravpoddar