The `delimiter` attribute of `<group>` is not applied to items inside `<choose>`
Opened this issue · 0 comments
Consider the following CSL snippet:
<group delimiter=". ">
<text value="v0"/>
<text value="v1"/>
<choose>
<if type="book">
<text value="v2"/>
<text value="v3"/>
</if>
</choose>
</group>
The complete test CSL file
<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" version="1.0" class="in-text" name-as-sort-order="all" sort-separator=" " demote-non-dropping-particle="never" initialize-with=" " initialize-with-hyphen="false" page-range-format="expanded" default-locale="zh-CN">
<info>
<title>test</title>
<id>http://test</id>
<category citation-format="numeric"/>
<category field="generic-base"/>
</info>
<macro name="entry-layout">
<group delimiter=". ">
<text value="v0"/>
<text value="v1"/>
<choose>
<if type="book">
<text value="v2"/>
<text value="v3"/>
</if>
</choose>
</group>
</macro>
<citation collapse="citation-number" after-collapse-delimiter=",">
<sort>
<key variable="citation-number"/>
</sort>
<layout vertical-align="sup" delimiter="," prefix="[" suffix="]">
<text variable="citation-number"/>
</layout>
</citation>
<bibliography>
<layout>
<text variable="citation-number" prefix="[" suffix="]"/>
<text macro="entry-layout"/>
</layout>
</bibliography>
</style>
Expected reference output: v0. v1. v2. v3
Actual reference output in Typst: v0. v1. v2v3
I noticed that when <group>
contains <choose>
, the group delimiter is not applied to elements inside <choose>
. Instead, <choose>
is treated as a group without a delimiter.
This behavior is inconsistent with reference management software like Zotero. In the CSL 1.0.2 documentation, it is stated:
Delimiters from the nearest delimiting element are applied within the output of
cs:choose
(i.e., the output of the matchingcs:if
,cs:else-if
, orcs:else
; see delimiter).src: https://docs.citationstyles.org/en/stable/specification.html#choose
P.S. Currently, this issue can be mitigated by nesting <group delimiter=". ">
inside <choose>
. However, this means that additional modifications to the CSL are required for it to work with Typst.
Example
<group delimiter=". ">
<text value="v0"/>
<text value="v1"/>
<choose>
<if type="book">
<group delimiter=". "> <!-- Add a nested group -->
<text value="v2"/>
<text value="v3"/>
</group> <!-- Add a nested group -->
</if>
</choose>
</group>