Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
csimide opened this issue Jun 11, 2024 · 0 comments
Open

Comments

@csimide
Copy link

csimide commented Jun 11, 2024

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

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
<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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant