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

Fix multi-line-fields in LF bibs on Windows #390

Closed
koppor opened this issue Jan 18, 2020 · 6 comments · Fixed by JabRef/jabref#8238
Closed

Fix multi-line-fields in LF bibs on Windows #390

koppor opened this issue Jan 18, 2020 · 6 comments · Fixed by JabRef/jabref#8238

Comments

@koppor
Copy link
Member

koppor commented Jan 18, 2020

If the .bib file has LF endings, multiline fields will be written using CRLF on Windows. - Should we add the line feed property to the meta data? (And write out accordingly?)

Steps:

  • create a bib file with LF line endings and a multi line field (e.g., comment)
  • add this file to .gitattributes with eol=lf
  • add a test case
  • Fix Bibdatabase writer

@koppor
Copy link
Member Author

koppor commented Jun 9, 2020

I have a LF file on Windows, opened it in JabRef, added a comment and saved it. This is the result:

grafik

bibWithUserCommentsAndEntryChange.bib

@koppor
Copy link
Member Author

koppor commented Jun 9, 2020

Aspects:

  • Read first 100 bytes to determine the new line character (and store it in memory of JabRef)
  • Normalization takes place within the edited entry (this explains the CRLF in 1137631)
  • Entries not touched are written as-is (with the existing line endings) this explains the LF in 1102917
  • Header is written in OS specific line ending (this explains the CRLF in the first two lines)

@koppor
Copy link
Member Author

koppor commented Oct 25, 2021

Solution strategy:

  • determine line ending of the file (or use preference line ending)
  • normalize all entries during reading

@koppor
Copy link
Member Author

koppor commented Oct 25, 2021

Pay attention on the "file changed on disk" thing, because when changing the line endings the file on disk changes, too.

@koppor
Copy link
Member Author

koppor commented Oct 25, 2021

This issue also triggers the "External changes" dialog for multiline fields:

grafik

File on disk looks good:

grafik

@JoKalliauer
Copy link

I have a LF file on Windows, opened it in JabRef, added a comment and saved it. This is the result:

@koppor : Could you provide your settings of

  • Options -> Preferences -> File -> Newline separator
  • Options -> Preferences -> File -> Always reformat BIB file on save and export

Screenshot from 2021-10-27 13-04-56_red

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

Successfully merging a pull request may close this issue.

2 participants