typst / hayagriva

Rusty bibliography management.
Apache License 2.0
347 stars 54 forks source link

The `delimiter` attribute of `<group>` is not applied to items inside `<choose>` #180

Open csimide opened 5 months ago

csimide commented 5 months ago

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 ```

Expected reference output: v0. v1. v2. v3
Actual reference output in Typst: v0. v1. v2v3

image

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 matching cs:if, cs:else-if, or cs: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 ```xml ```