Bug 401470 - Don't remove leading whitespace in macros
Summary: Don't remove leading whitespace in macros
Status: RESOLVED FIXED
Alias: None
Product: KBibTeX
Classification: Applications
Component: Loading/saving files (show other bugs)
Version: 0.8.1
Platform: Debian unstable Linux
: NOR normal
Target Milestone: ---
Assignee: Thomas Fischer
URL:
Keywords:
Depends on: 388892
Blocks:
  Show dependency treegraph
 
Reported: 2018-11-27 14:47 UTC by Stephan Beyer
Modified: 2018-12-24 20:44 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: c43b00e066f255ff9c12a0d930e4be8d8d60f41d


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Beyer 2018-11-27 14:47:25 UTC
SUMMARY

When a @string definition starts with whitespace, the whitespace is removed
when (or after) the file is loaded.  This may be a feature in the general
setting but destroys my author lists because I use something like the following
to have consistent repeated author names:

@string{and = " and "}
@string{author1 = "First Author"}
@string{author2 = "Second Author"}
@article{foo,
  author = author1 # and # author2,
  ...
}


STEPS TO REPRODUCE
1. Make a bib file containing the contents similar to the ones mentioned above.
2. Load the file into kbibtex.
3. Inside kbibtex, watch the BibTeX source of the first macro "and"
4. optionally: Save the file

OBSERVED RESULT
In step 3: "@string{and = {and }}"
In step 4: All your author information is now screwed because of the wrong "and" macro.

EXPECTED RESULT
In step 3: "@string{and = { and }}"
In step 4: Do not screw up author information.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.13.5
KDE Frameworks Version: 5.49.0
Qt Version: 5.11.1

ADDITIONAL INFORMATION
-
Comment 1 Thomas Fischer 2018-12-06 20:09:11 UTC
Please see the latest commit from branch 'bugs/kde401470' in my personal repository clone:
https://cgit.kde.org/clones/kbibtex/thomasfischer/kbibtex.git/log/?h=bugs/kde401470

This should fix the problem.

To test the code, please see here:
https://userbase.kde.org/KBibTeX/Development#Quick_Start_to_Run_KBibTeX_from_Git
but invoke the script as follows:
bash run-kbibtex.sh https://cgit.kde.org/clones/kbibtex/thomasfischer/kbibtex.git bugs/kde401470
Comment 2 Thomas Fischer 2018-12-22 20:15:51 UTC
Have you been able to check branch 'bugs/kde401470' and can confirm if the bug has been fixed?
Comment 3 Thomas Fischer 2018-12-24 20:44:38 UTC
Git commit c43b00e066f255ff9c12a0d930e4be8d8d60f41d by Thomas Fischer.
Committed on 06/12/2018 at 19:50.
Pushed by thomasfischer into branch 'kbibtex/0.8'.

Don't remove leading whitespace in macro

If a macro's text starts with one or more leading whitespaces,
replace all whitespaces with a single space.

M  +4    -1    src/io/fileimporterbibtex.cpp

https://commits.kde.org/kbibtex/c43b00e066f255ff9c12a0d930e4be8d8d60f41d
Comment 4 Thomas Fischer 2018-12-24 20:44:48 UTC
Git commit 46aaf2aa0166e2e2d42ccb069ef334b39512fca1 by Thomas Fischer.
Committed on 24/12/2018 at 20:38.
Pushed by thomasfischer into branch 'master'.

Don't remove leading whitespace in macro

If a macro's text starts with one or more leading whitespaces,
replace all whitespaces with a single space.

This commit is a manual forward-port of commit c43b00e066f255f
from branch 'kbibtex/0.8'.

M  +4    -1    src/io/fileimporterbibtex.cpp

https://commits.kde.org/kbibtex/46aaf2aa0166e2e2d42ccb069ef334b39512fca1