Juris-M / citeproc-js

A JavaScript implementation of the Citation Style Language (CSL) https://citeproc-js.readthedocs.io
Other
304 stars 85 forks source link

Italics aren't applied for second instance in field if "and" is present #229

Open dstillman opened 11 months ago

dstillman commented 11 months ago

Weird one!

https://forums.zotero.org/discussion/comment/363829/#Comment_363829

Testing with chicago-author-date

Placing this in the Volume field of an empty item results in FooBar an Baz in italics:

<i>Foo</i><i>Bar an Baz</i>

Title. Vol. *Foo*Bar an Baz.

But if "and" is present in the second string, the second string isn't italicized:

<i>Foo</i><i>Bar and Baz</i>

Title. 2023. Vol. Foo<i>Bar and Baz</i>.

zepinglee commented 11 months ago

Reproducible with this fixture where the CSL style is simplified.

I also test the content in fields title, edition, and page other than volume and it seems this bug only happens in number fields. I suspect it's related to citeproc-js parsing embedded locators in number fields (see test-suite/processor-tests/humans/number_OrdinalSpacing.txt).

BTW, since volume-title is available now, perhaps we can solve the original problem with it?

larsgw commented 11 months ago

Number fields are split here:

https://github.com/Juris-M/citeproc-js/blob/73bc1b44bc7d54d0bfec4e070fd27f5efe024ff9/src/util_number.js#L327-L362

They're then appended to the output queue here:

https://github.com/Juris-M/citeproc-js/blob/73bc1b44bc7d54d0bfec4e070fd27f5efe024ff9/src/util_number.js#L999

This then applies the formatting here:

https://github.com/Juris-M/citeproc-js/blob/73bc1b44bc7d54d0bfec4e070fd27f5efe024ff9/src/queue.js#L309

Since the parts are still being processed separately the "stray" tags are "neutralized", here:

https://github.com/Juris-M/citeproc-js/blob/73bc1b44bc7d54d0bfec4e070fd27f5efe024ff9/src/util_flipflop.js#L540-L559