Skip to content

Preserve no break spaces in Latex to Unicode conversion#15174

Open
faneeshh wants to merge 9 commits intoJabRef:mainfrom
faneeshh:fix-latex-unicode-nbsp
Open

Preserve no break spaces in Latex to Unicode conversion#15174
faneeshh wants to merge 9 commits intoJabRef:mainfrom
faneeshh:fix-latex-unicode-nbsp

Conversation

@faneeshh
Copy link
Contributor

@faneeshh faneeshh commented Feb 21, 2026

Closes #15158
PR Description

I updated the Latex to Unicode conversion to ensure the tilde (~) is converted to a non breaking space (\u00a0) instead of a standard space and I should mention that I used a negative lookbehind regex to make sure this only affects standalone tildes and doesn't break Latex tilde accents like ~{n}. I think this would maintain support for accented characters.

Screenshot

image

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • I added a screenshot in the PR description showing a library with a single entry with me as author and as title the issue number
  • I described the change in CHANGELOG.md in a way that can be understood by the average user (if change is visible to the user)
  • I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository

@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Feb 21, 2026
@qodo-free-for-open-source-projects
Copy link
Contributor

Review Summary by Qodo

Fix LaTeX tilde to non-breaking space conversion

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Replace LaTeX tildes with non-breaking spaces instead of standard spaces
• Use negative lookbehind regex to preserve LaTeX tilde accents like \~{n}
• Add test case for no-break space preservation in author names
• Update CHANGELOG with fix description
Diagram
flowchart LR
  A["LaTeX input with tilde"] -->|"negative lookbehind regex"| B["Standalone tildes identified"]
  B -->|"replace with \\u00a0"| C["Non-breaking space output"]
  D["LaTeX accents like \\~{n}"] -->|"not matched"| E["Preserved unchanged"]
Loading

Grey Divider

File Changes

1. jablib/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java 🐞 Bug fix +2/-1

Implement non-breaking space conversion for LaTeX tildes

• Added regex pattern (?<!\\\\)~ to match standalone tildes not preceded by backslash
• Replace matched tildes with Unicode non-breaking space character \u00a0
• Preserve LaTeX tilde accents by using negative lookbehind assertion

jablib/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java


2. jablib/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java 🧪 Tests +6/-1

Add tests for non-breaking space conversion

• Update existing test equationsMoreComplicatedFormatting to expect non-breaking space
• Add new test formatPreserveNoBreakSpaces to verify tilde conversion in author names
• Test case validates Y.~Matsumoto converts to Y.\u00a0Matsumoto

jablib/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java


3. CHANGELOG.md 📝 Documentation +1/-0

Document LaTeX tilde conversion fix

• Add entry documenting fix for LaTeX tilde to non-breaking space conversion
• Reference issue #15158 in the changelog entry
• Place entry in Fixed section with appropriate formatting

CHANGELOG.md


Grey Divider

Qodo Logo

@github-actions github-actions bot added the good first issue An issue intended for project-newcomers. Varies in difficulty. label Feb 21, 2026
@qodo-free-for-open-source-projects
Copy link
Contributor

qodo-free-for-open-source-projects bot commented Feb 21, 2026

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (3) 📎 Requirement gaps (0)

Grey Divider


Action required

1. NBSP breaks SQL search 🐞 Bug ✓ Correctness
Description
LatexToUnicodeAdapter.format now emits NBSP for ~, and the search index stores this value as the
transformed field. Because search queries use LIKE/ILIKE against the transformed column without
normalizing whitespace, searching with a normal space may no longer match entries whose transformed
text contains NBSP.
Code

jablib/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java[R33-34]

+        String toFormat = inField.replaceAll("(?<!\\\\)~", "\u00a0");
+        toFormat = UNDERSCORE_MATCHER.matcher(toFormat).replaceAll(REPLACEMENT_CHAR);
Evidence
The adapter replaces ~ with NBSP, the indexer persists LatexToUnicodeAdapter.format(value) as
FIELD_VALUE_TRANSFORMED, and SQL search uses LIKE/ILIKE comparisons against
FIELD_VALUE_TRANSFORMED with user-provided terms. LIKE/ILIKE are character-based, so U+0020
(space) does not match U+00A0 (NBSP).

jablib/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java[32-35]
jablib/src/main/java/org/jabref/logic/search/indexing/BibFieldsIndexer.java[474-476]
jablib/src/main/java/org/jabref/logic/search/query/SearchToSqlVisitor.java[280-299]
jablib/src/main/java/org/jabref/logic/search/query/SearchToSqlVisitor.java[551-555]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`LatexToUnicodeAdapter` now converts LaTeX `~` to NBSP (U+00A0). This value is written into the search index’s transformed column and is then queried using SQL LIKE/ILIKE. Because LIKE/ILIKE are character-sensitive, search terms containing normal spaces (U+0020) will not match transformed content containing NBSP.
## Issue Context
The adapter is used for both UI-ish formatting and backend indexing/search normalization. Preserving NBSP for display is desirable, but indexing/search likely needs whitespace normalization to maintain expected matching behavior.
## Fix Focus Areas
- jablib/src/main/java/org/jabref/logic/search/indexing/BibFieldsIndexer.java[474-476]
- jablib/src/main/java/org/jabref/logic/search/query/SearchToSqlVisitor.java[222-263]
- jablib/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java[32-35]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Inline regex in parse()📘 Rule violation ➹ Performance
Description
parse() uses String.replaceAll with a nontrivial regex, which recompiles the pattern on each
call and reduces readability. This violates the rule to prefer compiled Pattern reuse for regex
operations where applicable.
Code

jablib/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java[33]

+        String toFormat = inField.replaceAll("(?<!\\\\)~", "\u00a0");
Evidence
PR Compliance ID 14 requires compiling and reusing regex patterns via Pattern.compile(...) and
matcher(...) where applicable; the changed line uses an inline regex replacement directly in
replaceAll.

AGENTS.md
jablib/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java[33-33]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`LatexToUnicodeAdapter.parse()` uses an inline regex via `String.replaceAll`, which recompiles the pattern each time and conflicts with the guideline to use compiled `Pattern`s for nontrivial regex.
## Issue Context
The replacement regex contains a negative lookbehind and runs as part of `parse()`, which may be called frequently.
## Fix Focus Areas
- jablib/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java[33-34]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Changelog uses Latex spelling📘 Rule violation ✓ Correctness
Description
The new changelog entry uses Latex instead of the standard LaTeX spelling, which is a
typographical/style mistake in user-facing documentation. This reduces professionalism and
consistency of written content.
Code

CHANGELOG.md[45]

+- We fixed an issue where Latex to Unicode conversion replaced tildes with standard spaces instead of non-breaking spaces. ([#15158](https://github.com/JabRef/jabref/issues/15158))
Evidence
PR Compliance ID 28 requires new/modified changelog text to be free of typographical/formatting
mistakes; the added line uses the nonstandard capitalization Latex instead of LaTeX.

CHANGELOG.md[45-45]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changelog entry contains a typographical/style issue: `Latex` should be `LaTeX`.
## Issue Context
This is user-facing documentation and should match established terminology/capitalization used in the project.
## Fix Focus Areas
- CHANGELOG.md[45-45]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Advisory comments

4. Test name not self-documenting📘 Rule violation ✓ Correctness
Description
The new test method name formatPreserveNoBreakSpaces is grammatically awkward and uses a less
common term (NoBreak) instead of the clearer NonBreaking. This reduces readability and
self-documentation in tests.
Code

jablib/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java[R209-210]

+    void formatPreserveNoBreakSpaces() {
+        assertEquals("Y.\u00a0Matsumoto", formatter.format("Y.~Matsumoto"));
Evidence
PR Compliance ID 2 requires meaningful, self-documenting names; the added test name is less clear
than a conventional alternative like formatPreservesNonBreakingSpaces.

Rule 2: Generic: Meaningful Naming and Self-Documenting Code
jablib/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java[209-210]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The newly added test method name is not as clear/self-documenting as it could be.
## Issue Context
Test names serve as documentation for expected behavior; using conventional terminology improves readability.
## Fix Focus Areas
- jablib/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java[209-211]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Tilde after \\ not handled 🐞 Bug ✓ Correctness
Description
The negative lookbehind only converts ~ when not preceded by a backslash, so it will not convert
\~ (two backslashes then tilde). If such sequences are used in fields (and JabRef code treats them
as removable standalone tildes), NBSP preservation would be incomplete.
Code

jablib/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java[33]

+        String toFormat = inField.replaceAll("(?<!\\\\)~", "\u00a0");
Evidence
The replacement explicitly skips any tilde immediately preceded by \. JabRef’s own formatter tests
treat \\~ as a case where the tilde is not an accent command and should be processed (removed
there), suggesting it can appear as a standalone tilde in practice.

jablib/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java[32-34]
jablib/src/test/java/org/jabref/logic/layout/format/RemoveTildeTest.java[28-37]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The current negative-lookbehind replacement skips any `~` preceded by a backslash. This likely avoids breaking accent commands like `\~{n}`, but it also skips cases like `\\~` (two backslashes then tilde), which JabRef tests treat as a standalone tilde in other formatting contexts.
## Issue Context
Depending on intended LaTeX semantics in JabRef fields, `\\~` may represent a non-breaking space after a LaTeX command (or simply literal backslashes followed by a standalone tilde). If so, NBSP preservation would be incomplete.
## Fix Focus Areas
- jablib/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java[32-35]
- jablib/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java[133-212]
- jablib/src/test/java/org/jabref/logic/layout/format/RemoveTildeTest.java[28-37]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Comment on lines 33 to 34
String toFormat = inField.replaceAll("(?<!\\\\)~", "\u00a0");
toFormat = UNDERSCORE_MATCHER.matcher(toFormat).replaceAll(REPLACEMENT_CHAR);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Nbsp breaks sql search 🐞 Bug ✓ Correctness

LatexToUnicodeAdapter.format now emits NBSP for ~, and the search index stores this value as the
transformed field. Because search queries use LIKE/ILIKE against the transformed column without
normalizing whitespace, searching with a normal space may no longer match entries whose transformed
text contains NBSP.
Agent Prompt
## Issue description
`LatexToUnicodeAdapter` now converts LaTeX `~` to NBSP (U+00A0). This value is written into the search index’s transformed column and is then queried using SQL LIKE/ILIKE. Because LIKE/ILIKE are character-sensitive, search terms containing normal spaces (U+0020) will not match transformed content containing NBSP.

## Issue Context
The adapter is used for both UI-ish formatting and backend indexing/search normalization. Preserving NBSP for display is desirable, but indexing/search likely needs whitespace normalization to maintain expected matching behavior.

## Fix Focus Areas
- jablib/src/main/java/org/jabref/logic/search/indexing/BibFieldsIndexer.java[474-476]
- jablib/src/main/java/org/jabref/logic/search/query/SearchToSqlVisitor.java[222-263]
- jablib/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java[32-35]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@github-actions
Copy link
Contributor

Your pull request conflicts with the target branch.

Please merge with your code. For a step-by-step guide to resolve merge conflicts, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line.

@aniruddhkorde9-dot
Copy link

Hello! I am a new contributor looking to get involved. I would love to work on this issue. Could you please assign it to me?

@calixtus calixtus changed the title Fix #15158: Preserve no break spaces in Latex to Unicode conversion Preserve no break spaces in Latex to Unicode conversion Feb 21, 2026
@subhramit
Copy link
Member

Hello! I am a new contributor looking to get involved. I would love to work on this issue. Could you please assign it to me?

Are you aware that this is a PR and not an issue?

calixtus
calixtus previously approved these changes Feb 21, 2026
@testlens-app
Copy link

testlens-app bot commented Feb 21, 2026

🚨 TestLens detected 5 failed tests 🚨

Here is what you can do:

  1. Inspect the test failures carefully.
  2. If you are convinced that some of the tests are flaky, you can mute them below.
  3. Finally, trigger a rerun by checking the rerun checkbox.

Test Summary

Check Project/Task Test Runs
Source Code Tests / Unit tests – jablib :jablib:test BstPreviewLayoutTest > generatePreviewForSimpleEntryUsingAbbr()
Source Code Tests / Unit tests – jablib :jablib:test BstPreviewLayoutTest > generatePreviewForSliceTheoremPaperUsingAbbr()
Source Code Tests / Unit tests – jablib :jablib:test BstPreviewLayoutTest > generatePreviewForSliceTheoremPaperUsingIEEE()
Source Code Tests / Unit tests – jablib :jablib:test BstPreviewLayoutTest > monthMayIsCorrectlyRendered()
Source Code Tests / Unit tests – jablib :jablib:test CitationStyleGeneratorTest > doiFieldMapping(String, BibDatabaseMode, BibEntry, String, CitationStyleOutputFormat) > [6] "Corti, R., Flammer, A. J., Hollenberg, N. K., & Lüscher, T. F. (2009). Cocoa and Cardiovascular Health. Circulation, 119(10), 1433–1441. https://doi.org/10.1161/circ.108_827022 special\n", BIBLATEX, @Article{, author = {Corti, Roberto and Flammer, Andreas J. and Hollenberg, Norman K. and Lüscher, Thomas F.}, date = {2009-03}, doi = {10.1161/circ.108_827022~special}, issn = {1524-4539}, journaltitle = {Circulation}, number = {10}, pages = {1433--1441}, publisher = {Ovid Technologies (Wolters Kluwer Health)}, title = {Cocoa and Cardiovascular Health}, volume = {119}, _jabref_shared = {sharedId: -1, version: 1}}, "apa.csl", text

🏷️ Commit: 1586e0a
▶️ Tests: 11199 executed
⚪️ Checks: 61/61 completed

Test Failures

BstPreviewLayoutTest > generatePreviewForSimpleEntryUsingAbbr() (:jablib:test in Source Code Tests / Unit tests – jablib)
org.opentest4j.AssertionFailedError: expected: <O. Kopp. Thoughts on development.> but was: <O. Kopp. Thoughts on development.>
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:158)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:139)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:201)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:184)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:179)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1188)
	at org.jabref.jablib/org.jabref.logic.bst.BstPreviewLayoutTest.generatePreviewForSimpleEntryUsingAbbr(BstPreviewLayoutTest.java:28)
BstPreviewLayoutTest > generatePreviewForSliceTheoremPaperUsingAbbr() (:jablib:test in Source Code Tests / Unit tests – jablib)
org.opentest4j.AssertionFailedError: expected: <T. Diez. Slice theorem for fréchet group actions and covariant symplectic field theory. May 2014.> but was: <T. Diez. Slice theorem for fréchet group actions and covariant symplectic field theory. May 2014.>
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:158)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:139)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:201)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:184)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:179)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1188)
	at org.jabref.jablib/org.jabref.logic.bst.BstPreviewLayoutTest.generatePreviewForSliceTheoremPaperUsingAbbr(BstPreviewLayoutTest.java:46)
BstPreviewLayoutTest > generatePreviewForSliceTheoremPaperUsingIEEE() (:jablib:test in Source Code Tests / Unit tests – jablib)
org.opentest4j.AssertionFailedError: expected: <T. Diez, "Slice theorem for fréchet group actions and covariant symplectic field theory" May 2014.> but was: <T. Diez, "Slice theorem for fréchet group actions and covariant symplectic field theory" May 2014.>
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:158)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:139)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:201)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:184)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:179)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1188)
	at org.jabref.jablib/org.jabref.logic.bst.BstPreviewLayoutTest.generatePreviewForSliceTheoremPaperUsingIEEE(BstPreviewLayoutTest.java:53)
BstPreviewLayoutTest > monthMayIsCorrectlyRendered() (:jablib:test in Source Code Tests / Unit tests – jablib)
org.opentest4j.AssertionFailedError: expected: <O. Kopp. Thoughts on development, May.> but was: <O. Kopp. Thoughts on development, May.>
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:158)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:139)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:201)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:184)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:179)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1188)
	at org.jabref.jablib/org.jabref.logic.bst.BstPreviewLayoutTest.monthMayIsCorrectlyRendered(BstPreviewLayoutTest.java:39)
CitationStyleGeneratorTest > doiFieldMapping(String, BibDatabaseMode, BibEntry, String, CitationStyleOutputFormat) > [6] "Corti, R., Flammer, A. J., Hollenberg, N. K., & Lüscher, T. F. (2009). Cocoa and Cardiovascular Health. Circulation, 119(10), 1433–1441. https://doi.org/10.1161/circ.108_827022 special\n", BIBLATEX, @Article{, author = {Corti, Roberto and Flammer, Andreas J. and Hollenberg, Norman K. and Lüscher, Thomas F.}, date = {2009-03}, doi = {10.1161/circ.108_827022~special}, issn = {1524-4539}, journaltitle = {Circulation}, number = {10}, pages = {1433--1441}, publisher = {Ovid Technologies (Wolters Kluwer Health)}, title = {Cocoa and Cardiovascular Health}, volume = {119}, _jabref_shared = {sharedId: -1, version: 1}}, "apa.csl", text (:jablib:test in Source Code Tests / Unit tests – jablib)
org.opentest4j.AssertionFailedError: expected: <Corti, R., Flammer, A. J., Hollenberg, N. K., & Lüscher, T. F. (2009). Cocoa and Cardiovascular Health. Circulation, 119(10), 1433–1441. https://doi.org/10.1161/circ.108_827022 special
> but was: <Corti, R., Flammer, A. J., Hollenberg, N. K., & Lüscher, T. F. (2009). Cocoa and Cardiovascular Health. Circulation, 119(10), 1433–1441. https://doi.org/10.1161/circ.108_827022 special
>
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:158)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:139)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:201)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:184)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:179)
	at org.junit.jupiter.api@6.0.3/org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1188)
	at org.jabref.jablib/org.jabref.logic.citationstyle.CitationStyleGeneratorTest.doiFieldMapping(CitationStyleGeneratorTest.java:946)

Muted Tests

Select tests to mute in this pull request:

  • BstPreviewLayoutTest > generatePreviewForSimpleEntryUsingAbbr()
  • BstPreviewLayoutTest > generatePreviewForSliceTheoremPaperUsingAbbr()
  • BstPreviewLayoutTest > generatePreviewForSliceTheoremPaperUsingIEEE()
  • BstPreviewLayoutTest > monthMayIsCorrectlyRendered()
  • CitationStyleGeneratorTest > doiFieldMapping(String, BibDatabaseMode, BibEntry, String, CitationStyleOutputFormat)

Reuse successful test results:

  • ♻️ Only rerun the tests that failed or were muted before

Click the checkbox to trigger a rerun:

  • Rerun jobs

Learn more about TestLens at testlens.app.


private static final Pattern TILDE_MATCHER = Pattern.compile("(?<!\\\\)~");

private static final String NON_BREAKING_SPACE = "\u00a0";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static final String NON_BREAKING_SPACE = "\u00a0";
private static final String NO_BREAK_SPACE = "\u00a0";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formal unicode character name is "no-break" space (https://www.unicode.org/charts/charindex.html), which I think is a better choice than the alternative name "non-breaking space" unless JabRef has a precedent of using the alternative. Thanks for the fix, @faneeshh.

/// @return an `Optional<String>` with LaTeX resolved into Unicode or `empty` on failure.
public static Optional<String> parse(@NonNull String inField) {
String toFormat = UNDERSCORE_MATCHER.matcher(inField).replaceAll(REPLACEMENT_CHAR);
String toFormat = TILDE_MATCHER.matcher(inField).replaceAll(NON_BREAKING_SPACE);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String toFormat = TILDE_MATCHER.matcher(inField).replaceAll(NON_BREAKING_SPACE);
String toFormat = TILDE_MATCHER.matcher(inField).replaceAll(NO_BREAK_SPACE);

}

@Test
void formatPreservesNoBreakingSpaces() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void formatPreservesNoBreakingSpaces() {
void formatPreservesNoBreakSpaces() {

CHANGELOG.md Outdated

### Fixed

- We fixed an issue where LaTeX to Unicode conversion replaced tildes with standard spaces instead of non-breaking spaces. ([#15158](https://github.com/JabRef/jabref/issues/15158))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- We fixed an issue where LaTeX to Unicode conversion replaced tildes with standard spaces instead of non-breaking spaces. ([#15158](https://github.com/JabRef/jabref/issues/15158))
- We fixed an issue where LaTeX to Unicode conversion replaced tildes with standard spaces instead of no-break spaces. ([#15158](https://github.com/JabRef/jabref/issues/15158))

calixtus
calixtus previously approved these changes Feb 23, 2026
@calixtus calixtus enabled auto-merge February 23, 2026 21:51
@Siedlerchr
Copy link
Member

8
BibEntryTest > getFieldOrAliasLatexFreeComplexConversionInAlias() FAILED
org.opentest4j.AssertionFailedError at BibEntryTest.java:243

@subhramit subhramit disabled auto-merge February 23, 2026 22:34
@faneeshh
Copy link
Contributor Author

8 BibEntryTest > getFieldOrAliasLatexFreeComplexConversionInAlias() FAILED org.opentest4j.AssertionFailedError at BibEntryTest.java:243

8 BibEntryTest > getFieldOrAliasLatexFreeComplexConversionInAlias() FAILED org.opentest4j.AssertionFailedError at BibEntryTest.java:243

I'm guessing it's failing because it expects a standard space where I've now introduced the no-break space(\u00a0)? If that is the case then should I update the test's expected string to match the new Unicode char? Does that sound right

@jabref-machine
Copy link
Collaborator

JUnit tests of jablib are failing. You can see which checks are failing by locating the box "Some checks were not successful" on the pull request page. To see the test output, locate "Source Code Tests / Unit tests (pull_request)" and click on it.

You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide.

@faneeshh
Copy link
Contributor Author

It looks like my change is introducing no-break spaces into generated previews and DOIs. I can update the tests to expect \u00a0 but I feel like that might break DOI links if a user copies them. Should i restrict the conversion so it doesn't affect DOIs or should I update the test assertions

@calixtus
Copy link
Member

Interesting unexpected side effect. Will label as Devcall discussion.

@subhramit
Copy link
Member

@faneeshh you can work on something else in the meanwhile if you wish to. Feel free to ping if you get "maximum assignment limit reached".

@faneeshh
Copy link
Contributor Author

@faneeshh you can work on something else in the meanwhile if you wish to. Feel free to ping if you get "maximum assignment limit reached".

I really appreciate the concern. I was lurking around this SLR support improving issue (#12642). I ended up reading through the old reverted PR history and I really feel like I have an overview in my mind of how to fix the missing V2 requirements. Now this might be a bit of a long shot but I could try implementing a cleaner foundation for the study.yaml format and see if I can get the migrator and those string based tests right... @koppor Let me know what you think of the same...

@subhramit
Copy link
Member

Now this might be a bit of a long shot but I could try implementing a cleaner foundation for the study.yaml format and see if I can get the migrator and those string based tests right... @koppor Let me know what you think of the same...

Please feel free to go ahead, we can comment further once you give a solution sketch or a draft PR.

@koppor
Copy link
Member

koppor commented Feb 26, 2026

like that might break DOI links if a user copies them

Will also happen when spaces are introduced.

I am not sure when DOIs contain ~

If URLs contain ~, they should be kept.

Maybe follow-up issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

good first issue An issue intended for project-newcomers. Varies in difficulty. status: changes-required Pull requests that are not yet complete status: devcall

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert LaTeX to Unicode feature should preseve no-break spaces

8 participants