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

Introduce formatter to remove word-enclosing braces #11222

Closed
koppor opened this issue Apr 18, 2024 · 0 comments · Fixed by #11253
Closed

Introduce formatter to remove word-enclosing braces #11222

koppor opened this issue Apr 18, 2024 · 0 comments · Fixed by #11253
Labels
cleanup-ops good first issue An issue intended for project-newcomers. Varies in difficulty.

Comments

@koppor
Copy link
Member

koppor commented Apr 18, 2024

We have RemoveBracesFormatter, which removes the outer braces. See org.jabref.logic.formatter.bibtexfields.RemoveBracesFormatterTest for examples.

We have org.jabref.model.entry.Author#removeStartAndEndBraces, which also removes inner braces enclosing complete words:

  • {Vall{\'e}e} {Poussin} -> Vall{\'e}e Poussin <-- here, {Poussin} is changed to Poussin. This is not available to users (in the cleanup entry dialogue)
  • {Vall{\'e}e Poussin} -> Vall{\'e}e Poussin <-- here, the outer braces are removed
  • Vall{\'e}e Poussin -> Vall{\'e}e Poussin <-- here, everything is kept as is

We should make this formatter "globally" available:

  1. Rename RemoveBracesFormatter to RemoveEnclosingBracesFormatter.
    • Also rename all used fields.
  2. Introduce RemoveWordEnclosingAndOuterEnclosingBracesFormatter by moving the code of org.jabref.model.entry.Author#removeStartAndEndBraces to here
    • Introduce class
    • Create test cases (similar to RemoveBracesFormatterTest)
    • Replace call to removeStartAndEndBraces in Author to call to RemoveWordEnclosingAndOuterEnclosingBracesFormatter.format. The RemoveWordEnclosingAndOuterEnclosingBracesFormatter needs to be initialized as class constant in Author
    • Name the formatter "Remove word enclosing braces"
    • Use description "Removes braces encapsulating a complete word and the complete field content."
  3. Create a pull request for the user documentation (update the page https://docs.jabref.org/finding-sorting-and-cleaning-entries/saveactions#remove-enclosing-braces).
@koppor koppor added good first issue An issue intended for project-newcomers. Varies in difficulty. cleanup-ops labels Apr 18, 2024
rohit-garga added a commit to rohit-garga/jabref that referenced this issue Apr 26, 2024
github-merge-queue bot pushed a commit that referenced this issue May 13, 2024
* #11222 fix

* checkstyle fixes

* fixes for unit tests

* Make new RemoveWordEnclosingAndOuterEnclosingBracesFormatter available

* Add more braces to the example input

* Keep original string when formatting empty string

* Fix RemoveWordEnclosingAndOuterEnclosingBracesFormatter in the case of }} at the end

* Fix constant (and empty line)

* Reorder methods

* Add CHANGELOG.md entry

* markdown issue fix

* checkstyle fix

* duplicate keys issue fix

* author class not being initialized fix

* reverting key name change for old formatter

* reverting commit- Keep original string when formatting empty string since it causes unit tests to fail

* minor fixes

* minor fixes

* minor fixes

* fix: rewrite

* formatting fix

---------

Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup-ops good first issue An issue intended for project-newcomers. Varies in difficulty.
Projects
Archived in project
1 participant