JabRef / jabref

Graphical Java application for managing BibTeX and biblatex (.bib) databases
https://devdocs.jabref.org
MIT License
3.64k stars 2.59k forks source link

Sanitization of generated filenames (remove LaTeX commands) #12188

Open pcdi opened 1 week ago

pcdi commented 1 week ago

Is your suggestion for improvement related to a problem? Please describe. For linked files, when they are renamed automatically according to filename format pattern, the fields that are used to generate the new filename are not stripped of LaTeX commands, so these LaTeX commands show up in the filename.

Consider the following example:

@Article{BrayBuildingCommunity,
  author       = {David Bray},
  date         = {2006},
  journaltitle = {Economy and Society},
  number       = {4},
  pages        = {530--549},
  title        = {Building \mkbibquote{Community}},
  volume       = {35},
  doi          = {10.1080/03085140600960799},
  subtitle     = {New Strategies of Governance in Urban China},
}

If the pattern is set to [bibtexkey] - [fulltitle], then the generated filename will be BrayBuildingCommunity - Building _mkbibquote_Community_.pdf. In this case, only \ and {} are sanitized to _ but the command name mkbibquote remains.

Describe the solution you'd like The filename generation function should be able to strip fields that are used to create the filename of LaTeX commands (even if only optionally). In the above example, the generated filename should then be BrayBuildingCommunity - Building Community.pdf.

koppor commented 1 week ago

Implementation hint: We have the latex-to-unicode formatter. It should be used in the filename conversion.

  1. Find code place where to add
  2. Find tests (possible simply by Ctrl+Shift+T
  3. Add refined test case
  4. See tests failing
  5. Fix code

In case latex-to-unicode does not know this command, think harder of how to do step 5. Maybe use remove-latex-commands? Check the functionality - because the parameters inside the latex command should be kept.

Siedlerchr commented 1 week ago

We should rather use RemoveLatexCommandsFormatter as Latex2Unicode can produce weird characters you don't probably want

yoyounik commented 1 week ago

Hii @koppor can i be assigned this issue to work on

koppor commented 1 week ago

/assign @yoyounik

github-actions[bot] commented 1 week ago

👋 Hey @yoyounik, thank you for your interest in this issue! 🎉

We're excited to have you on board. Start by exploring our Contributing guidelines, and don't forget to check out our workspace setup guidelines to get started smoothly.

In case you encounter failing tests during development, please check our developer FAQs!

Having any questions or issues? Feel free to ask here on GitHub. Need help setting up your local workspace? Join the conversation on JabRef's Gitter chat. And don't hesitate to open a (draft) pull request early on to show the direction it is heading towards. This way, you will receive valuable feedback.

Happy coding! 🚀

⏳ Please note, you will be automatically unassigned if the issue isn't closed within 30 days (by 14 December 2024). A maintainer can also add the "📌 Pinned"" label to prevent automatic unassignment.

yoyounik commented 1 week ago

Hey @koppor i have raise a PR for this: https://github.com/JabRef/jabref/pull/12194

please check it once, whenever you get the time, Thanks :)