Fix handling of trailing whitespaces in initials' delimiters #257
+82
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #137
Some styles, such as
vancouver
, require there to be nothing between initials, soAstley, Rick Gavin
would be formatted asAstley, RG
instead ofAstley, R. G.
(more usual) orAstley, R G
for example. However, even when settinginitializer-with=""
(empty delimiter), Hayagriva was still forcing whitespaces between initials.It was thought that #150 would have fixed it by only adding whitespaces if a delimiter was indeed specified, but it actually didn't change anything as there is always a delimiter - however, it is sometimes an empty string. While adding an explicit check for empty strings would have fixed this specific problem, it turns out Hayagriva's behavior of forcing a whitespace to always be added after the delimiter, replacing any of its trailing whitespaces if there are any (otherwise, one is added anyways), is not consistent with other CSL processors. Indeed, several citeproc tests demonstrated that the expected way to add whitespaces between initials is through
initializer-with=". "
instead ofinitializer-with="."
. So, I removed Hayagriva's automatic whitespace behavior, except when we're replacing hyphens (e.g. forinitializer-with=". "
,Aa-Bb
should becomeA.-B.
and notA. -B.
).It is, however, unfortunate that this seems to be somewhat inconsistent with a specific example given by the relevant section of the CSL 1.0.2 spec:
...but most official styles I've seen appear to assume that whitespaces are preserved, using
". "
instead of"."
in that case. So this seems to be the way to go.I've also added some tests. Two more citeproc tests are now passing as well.
I'll be keeping this as a draft as I still need to test the case with
initialize="false", initialize-with="."
, but in principle the code seems to preserve whitespace here as well, however whitespaces from the name itself are also kept, which is whyinitialize-with="."
is used instead ofinitialize-with=". "
by official styles in this case.