-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] CSL citations: Fix sync numbering #11688
Conversation
@subhramit Issue migration is separate from this PR. Do you intend to keep your fork? If yes, we can keep the issues as is and do the refinement when time allows. On case you are going to delete it, we need to prioritize the issue refinement (which I would do only if absolutely necessary). |
Of course, I will be keeping my fork, I wish to continue contributing. There is no hurry. We can take our time. Point behind issue migration is just to keep them free-to-take and give more detailed context to contributors (by refining). With regards to this particular issue, I expect people using numeric styles to anyway raise this soon enough when they face it. |
@antalk2 Karoly, if you ever get some time to go through this, I'd love to know your suggestions. The PR description is a bit more detailed, but to summarise, I have questions like: "how to generate a combined citation mark", "what could be a possible way to deal with the variety in CSL" and finally, "how can one make a unified system for anchoring the reference marks, changing them as well as changing the citation text when its surrounding characters or separators are not known"...Maybe even some suggestions for simplification for the case of single entry citations -> as you can see I am confused why starting with "1" bugs out, and text is updated in the reverse order, with the reference marks getting updated with We can ignore other safety mechanisms like "check if cursor is in restricted area", "what if mark is in footer", etc. that you implemented in JStyles, for now. If the changes in this PR are not neat (well, they are not neat) or weird, you can check out the unchanged files for the current implementation (it does not have the update citations functionality when order changes/ middle element is deleted). A relevant update which may help: .csl files can be parsed to get the prefix, suffix and delimiter. [as per last discussion with @Siedlerchr] |
I thought CSL does that. We just have to insert the result.
Is this about parsing the CSL output? My impression is that you are trying to parse the CSL output in order Updating citation groups (calculating the text to be inserted) is already hard I never finished reading about all the features of CSL, but already met some
The upshot is:
The flow of information would be
So the information flow:
No parsing of CSL output, just comparing old and new output, or new Terminology: I started to use the terms "CitationGroup" and "Citation" before I looked at |
Fixed this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code currently does not meet JabRef's code guidelines.
We use OpenRewrite to ensure "modern" Java coding practices.
The issues found can be automatically fixed.
Please execute the gradle task rewriteRun
, check the results, commit, and push.
You can check the detailed error output by navigating to your pull request, selecting the tab "Checks", section "Tests" (on the left), subsection "OpenRewrite".
Added number re-distribution in #11712. |
@Siedlerchr I suppose we can close this? I don't think we have anything left to experiment with, in the context. |
This PR is a work in progress, and is open to anyone who wishes to work on it. Consider this a very rough playground with no focus on code quality (till we get the functionality right). Effort needed for testing will be a bit high, as you need to test using LibreOffice every time you implement something new.
Aim:
To try to solve the issue subhramit#22 (actually an extended version of it - as the citation numbering should update on changing the order of citations in the document as well, not just deletion, although both of them will have the same solution - to update the citation text as well as reference mark whenever a new entry is cited).
Current progress (starting point) on this PR:
I have been able to update the citation numbers (after insertion of the ciattions), but as a consequence of my changes, the following issues exist that I am unable to solve:
public int getCitationNumber(String citationKey)
. If I change the default to 1, the behavior begins to be weird. One needs to investigate.CID
of 0. This needs to be fixed. Many moving parts to keep track of.a) In the current implementation, when citing a group of entries, the citation text is not draped with a combined reference mark, rather the reference mark for each entry is inserted one by one after the citation text. Reason: I could not find a way on how to segment the grouped citation so that each number gets its respective reference mark. Or, how to generate a combined reference mark for all entries in the group and parse them (maybe one can look at how JStyles does it, but it is complicated, and also makes some assumptions based on the specified opening/closing braces, which may not apply to CSL). Result: This makes them difficult to anchor or trace, or update. The was also because CSL styles have a lot of variety when it comes to formatting and the separators between them (for a group of entries).
b) As a result of (a), even if we are able to make a working model for single citations, we cannot apply it to citation groups (when it comes to updating their text, as well as the reference marks, due to the positioning as well as variety in "what brace or separator surrounds the number" - some styles have no braces, only formatting such as
<sup>
, which cannot be parsed from the document (they are as good as naked numbers as we can get the text, but not the formatting details) - so regex parsing won't apply, as the rest of the document can have both braces and/or numbers).However, it is upto whoever takes this problem if they want to make a working model for single citations first. For that, we just need to solve points 1, 2, 3 and 4.
I would specially invite @Siedlerchr and other maintainers to work on this whenever they find time.
What we have at our disposal: Look at the code for how JStyle numbers are synced, and also how https://github.com/zotero/zotero-libreoffice-integration does it.
Note:
The issues need to be migrated to
JabRef:main
as I alone would not be able to solve them. Two of them are potentially good Candidates for University Projects or medium GSoC projects (large if combined with Zotero format migration + unification of JStyle/CSL style backend). I would ask @ThiloteE or @koppor (the authors of the issues) to migrate them as open issues with a more detailed framing. (maybe melting pot? I would like to help). The link to the issue above needs to be updated once migration is done.Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)