Skip to content
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

Space before citations in Openoffice/Libreoffice integration #10843

Merged
merged 2 commits into from
Jan 30, 2024

Conversation

lwlR
Copy link
Contributor

@lwlR lwlR commented Jan 30, 2024

By default, zero width space is added in front of each citation in the text in Openoffice/Libreoffice. This causes ugly line breaks if new line starts with a citation:

grafik

To allow changing if a zero width space is added to each citation, a new boolean in the style file can be used:
SpaceBefore="true" -> Default behaviour with the zero width space
SpaceBefore="false" -> No space is added:

grafik

Pull request to documentation added.

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

… to switch between ZERO_WIDTH_SPACE (default) and no space added
CHANGELOG.md Outdated Show resolved Hide resolved
@Siedlerchr
Copy link
Member

Thanks for your contribution, lgtm so far. Can you please update the documentation as well?
https://docs.jabref.org/cite/openofficeintegration#the-style-file

You can edit it by clicking on the 3 dots:
grafik

@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jan 30, 2024
@calixtus
Copy link
Member

Great feature. Thank you for digging into this!

@calixtus calixtus added this pull request to the merge queue Jan 30, 2024
Merged via the queue into JabRef:main with commit c848055 Jan 30, 2024
19 checks passed
Siedlerchr added a commit that referenced this pull request Feb 3, 2024
* upstream/main:
  Update deployment-arm64.yml
  fix linebreak
  fix condition
  Update deployment-arm64.yml
  rename
  Update deployment-arm64.yml
  Switch to arm runner macos14
  Update journal abbreviation lists (#10846)
  Fix Suggestion Provider for Crossref during autocompletion disable (#10829)
  Update CSL styles (#10844)
  Space before citations in Openoffice/Libreoffice integration (#10843)
@antalk2
Copy link
Contributor

antalk2 commented Mar 25, 2024

Two comments

  • ZERO_WIDTH_SPACE = "\u2060" // "WORD JOINER"
    would probably solve the above problem without a need for an extra flag (SpaceBefore)

  • Unfortunately I cannot exactly remember why I introduced the ZERO_WIDTH_SPACE. Whatever that was,
    SpaceBefore="false" might reintroduce it. On the other hand: if it causes no problems, than ZERO_WIDTH_SPACE
    is not needed (unless the user wishes to directly format the citation mark to something it otherwise would not inherit).

Details below

The problem solved by SpaceBefore="false"

At first, I did not understand the problem solved here.
Now I think I do:

LibreOffice

  • can break the line after a zero width space (ZERO_WIDTH_SPACE = "\u200b") and
  • when justifying a line considers this otherwise invisible ZERO_WIDTH_SPACE a word, thus leaves some space before it.
    This makes the visible line endings ragged.

"WORD JOINER"

Question: would it help if we used the "WORD JOINER" U+2060 ("\u2060") (https://unicode-explorer.com/c/2060) instead?

  • At an automatic line break (after a space), the "WORD JOINER" character sticks to the next (non-space) character, i.e. it is not positioned before the automatic line break, thus does not create ragged lines.
  • If there is no space before the "WORD JOINER", then there is no automatic line break created before it.

(Tested in LibreOffice 7.6.4.1 by inserting a "WORD JOINER" by copying it from https://unicode-explorer.com/c/2060)

So yes, changing the value of ZERO_WIDTH_SPACE to "\u2060" would probably solve the problem without
using the SpaceBefore flag introduced here (assuming citation markers never start with a space).

Does ZERO_WIDTH_SPACE matter? (Why did I introduce the ZERO_WIDTH_SPACE?)

  • When we update a citation mark, its text is removed and the new text is inserted.
  • The new text inherits its character formatting from "the context".
  • If there is a character (within the same paragraph) before the insertion point, it provides "the context" for this inheritance. If there is none, LO looks somewhere else (maybe the character after the insertion point, and if the is none, then ...)

So what the ZERO_WIDTH_SPACE achieves is that if the user directly formats the citation mark -- in particular the invisible space at the beginning -- to for example highlighted, then the above procedure will preserve this (and extend it to the whole marker when updated) .

Well, this sounds nice, but only moderately important: SpaceBefore=false should be basically OK unless the user wishes to directly format the citation mark.

Yet, I have a vague recollection of introducing this ZERO_WIDTH_SPACE after making cleanFillCursor to remove the brackets (REFERENCE_MARK_LEFT_BRACKET and REFERENCE_MARK_RIGHT_BRACKET), because of some actual problem I encountered (as opposed to theoretical worries).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants