How to parse BibTex "@incollection" or Hayagriva "type: anthos, parent-type: anthology" entry in CSL?

Hi Peter,

I found the same issue. As PgBiel mentioned, the "anthos"type is not translated into a CSL type. I am creating a CSL style and added a debug macro that compares bibliography entries with all CSL types and print the one that match. My macro print “unknown” if no match is found. My CSL style with the macro function is hidden below:

Summary
<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never">
  <info>
    <title>DACT’s ABNT Numeric</title>
    <id>dact-abnt-numeric</id>
  </info>
  <macro name="debug">
<choose>
<if type="article">
<text value="article"/>
</if>
<else-if type="article-journal">
<text value="article-journal"/>
</else-if>
<else-if type="article-magazine">
<text value="article-magazine"/>
</else-if>
<else-if type="article-newspaper">
<text value="article-newspaper"/>
</else-if>
<else-if type="bill">
<text value="bill"/>
</else-if>
<else-if type="book">
<text value="book"/>
</else-if>
<else-if type="broadcast">
<text value="broadcast"/>
</else-if>
<else-if type="chapter">
<text value="chapter"/>
</else-if>
<else-if type="classic">
<text value="classic"/>
</else-if>
<else-if type="collection">
<text value="collection"/>
</else-if>
<else-if type="dataset">
<text value="dataset"/>
</else-if>
<else-if type="document">
<text value="document"/>
</else-if>
<else-if type="entry">
<text value="entry"/>
</else-if>
<else-if type="entry-dictionary">
<text value="entry-dictionary"/>
</else-if>
<else-if type="entry-encyclopedia">
<text value="entry-encyclopedia"/>
</else-if>
<else-if type="event">
<text value="event"/>
</else-if>
<else-if type="figure">
<text value="figure"/>
</else-if>
<else-if type="graphic">
<text value="graphic"/>
</else-if>
<else-if type="hearing">
<text value="hearing"/>
</else-if>
<else-if type="interview">
<text value="interview"/>
</else-if>
<else-if type="legal_case">
<text value="legal_case"/>
</else-if>
<else-if type="legislation">
<text value="legislation"/>
</else-if>
<else-if type="manuscript">
<text value="manuscript"/>
</else-if>
<else-if type="map">
<text value="map"/>
</else-if>
<else-if type="motion_picture">
<text value="motion_picture"/>
</else-if>
<else-if type="musical_score">
<text value="musical_score"/>
</else-if>
<else-if type="pamphlet">
<text value="pamphlet"/>
</else-if>
<else-if type="paper-conference">
<text value="paper-conference"/>
</else-if>
<else-if type="patent">
<text value="patent"/>
</else-if>
<else-if type="performance">
<text value="performance"/>
</else-if>
<else-if type="periodical">
<text value="periodical"/>
</else-if>
<else-if type="personal_communication">
<text value="personal_communication"/>
</else-if>
<else-if type="post">
<text value="post"/>
</else-if>
<else-if type="post-weblog">
<text value="post-weblog"/>
</else-if>
<else-if type="regulation">
<text value="regulation"/>
</else-if>
<else-if type="report">
<text value="report"/>
</else-if>
<else-if type="review">
<text value="review"/>
</else-if>
<else-if type="review-book">
<text value="review-book"/>
</else-if>
<else-if type="software">
<text value="software"/>
</else-if>
<else-if type="song">
<text value="song"/>
</else-if>
<else-if type="speech">
<text value="speech"/>
</else-if>
<else-if type="standard">
<text value="standard"/>
</else-if>
<else-if type="thesis">
<text value="thesis"/>
</else-if>
<else-if type="treaty">
<text value="treaty"/>
</else-if>
<else-if type="webpage">
<text value="webpage"/>
</else-if>
<else>
<text value="unknown"/>
</else>
</choose>
</macro>
  <macro name="title">
    <choose>
      <if type="book collection report" match="any">
        <text variable="title" font-style="italic" text-case="title"/>
      </if>
      <else>
        <text variable="title" text-case="title"/>
      </else>
    </choose>
  </macro>
  <!-- I use &#160; as non-breaking space -->
  <citation collapse="citation-number">
    <layout vertical-align="sup" delimiter=",&#160;">
      <group delimiter=",&#160;">
        <text variable="citation-number"/>
        <group delimiter="&#160;">
          <label variable="locator" form="short"/>
          <text variable="locator"/>
        </group>
      </group>
    </layout>
  </citation>
  <bibliography second-field-align="flush">
    <layout>
      <text variable="citation-number"/>
      <group delimiter=". " suffix=".">
        <names variable="author">
          <name delimiter="; " initialize-with="." name-as-sort-order="all"/>
          <label form="short" prefix=" (" suffix=")"/>
          <substitute>
            <names variable="editor"/>
          </substitute>
        </names>
        <text macro="title"/>
        <text variable="edition" suffix=". ed."/>
        <group delimiter=", ">
          <group>
            <text variable="publisher-place"/>
            <text variable="publisher" prefix=": "/>
          </group>
          <text variable="container-title" font-style="italic"/>
          <text variable="volume" prefix="v. "/>
          <text variable="issue" prefix="n. "/>
          <text variable="page" prefix="p. "/>
          <date variable="issued" delimiter=" ">
            <date-part name="day"/>
            <date-part name="month" form="short"/>
            <date-part name="year"/>
          </date>
        </group>
        <text variable="DOI" prefix="DOI: "/>
      </group>
      <text macro="debug" prefix=" <debug>" suffix="</debug>"/>
    </layout>
  </bibliography>
</style>

Example in Typst:

#show regex("<debug>.*?</debug>"): it => {
  set text(fill: blue)
  show regex("unknown"): set text(fill: red)
  show "<debug>": ""
  show "</debug>": ""
  it
}

#bibliography("bibliography.yml", style: "dact-abnt-numeric.csl")

Note that reference 2 is of type “anthology”, and it is correctly translated into a CSL “collection”. Reference 5, however, is of type “anthos” and a CSL type is not assigned. The Hayagriva source:

Jones2001:
  type: anthology
  title: Wind stress over the ocean
  editor:
    - Jones, Ian S. F.
    - Toba, Yoshiaki
  date: 2001
  publisher:
    name: University Press
    location: Cambridge

Donelan1979:
  type: anthos
  title: On the fraction of wind momentum retained by waves
  author: Donelan, M.
  date: 1979
  page-range: 141-159
  parent:
    title: "Marine forecasting: predictability and modelling in ocean hydrodynamics"
    editor: Nihoul, Jacques C. J.
    publisher:
      name: Elsevier
      location: Amsterdam
  serial-number:
    doi: 10.1016/s0422-9894(08)71128-0

For now, I think I will use the “chapter” type, which is translated to CSL “chapter” type, though I am not sure if it is semantically appropriate for this type of work. Perhaps I could define parent type as “anthology” since “chapter” parent is “book” by default.

I will open an issue in Hayagriva’s repo if there is not already one.

2 Likes