Why is there a discrepancy between Typst's and Pandoc's CSL engines for @inbook entries?

I am currently writing a CSL format reproducing BibTeX’s plain bibliography style. However, I have problems handling the @inbook entries in BibTeX files. Here is an example:

test-bibliography.bib

@inbook{dirac1930,
  author       = {Dirac, Paul A. M.},
  title        = {The Principles of Quantum Mechanics},
  chapter      = {3},
  publisher    = {Oxford University Press},
  year         = {1930},
  pages        = {50--75},
}

When I convert it to CSL-JSON using the Pandoc online converter, I get the following:

[
  {
    "author": [
      {
        "family": "Dirac",
        "given": "Paul A. M."
      }
    ],
    "chapter-number": "3",
    "id": "dirac1930",
    "issued": {
      "date-parts": [
        [
          1930
        ]
      ]
    },
    "page": "50-75",
    "publisher": "Oxford University Press",
    "title": "The principles of quantum mechanics",
    "type": "chapter"
  }
]

So, with the CSL engine of Pandoc, @inbook is converted to chapter. However, apparently, this entry type is not converted to chapter by Typst’s CSL engine. Here is a minimal example of a CSL and Typst document that reproduces my problem.

test.csl

<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" version="1.0" class="in-text" default-locale="en-US">
  <info>
    <title>Test</title>
    <id>http://www.zotero.org/styles/test</id>
  </info>

  <citation>
    <layout prefix="[" suffix="]" delimiter=", ">
      <text variable="citation-number"/>
      <text variable="locator"/>
    </layout>
  </citation>

  <bibliography>
    <layout>
      <text variable="citation-number" prefix="[" suffix="] "/>
      <choose>
        <if type="chapter"><text value="***CHAPTER FOUND***"/></if>
        <else><text value="***NOT A CHAPTER***"/></else>
      </choose>
    </layout>
  </bibliography>

</style>

test.typ

@dirac1930

#bibliography("test-bibliography.bib", style: "test.csl")

Result:

Note: @inbook is not the only BibTeX type that has this problem. All the following types are not converted to the same CSL type as Pandoc.

BibTeX type Pandoc’s CSL type
@inbook "chapter"
@booklet "pamphlet"
@manual "book"
@incollection "chapter"

I assume Typst’s CSL engine converts all these BibTeX types to the empty "" CSL type, like for @misc entries, but I currently have no way to check that for sure. If someone knows a way to get the type given by Typst, it would be very helpful for debugging.

Here are examples of some problematic BibTeX entries to reproduce the bug.

@inbook{dirac1930,
  author       = {Dirac, Paul A. M.},
  title        = {The Principles of Quantum Mechanics},
  chapter      = {3},
  publisher    = {Oxford University Press},
  year         = {1930},
  pages        = {50--75},
}

@booklet{sampleBooklet,
  title        = {Quick Reference Guide to Linux Commands},
  author       = {Smith, Jane},
  howpublished = {Privately printed},
  year         = {2021},
  note         = {Available online at https://example.com/linux-guide},
}

@manual{pythonManual,
  title        = {Python Language Reference, Version 3.11},
  organization = {Python Software Foundation},
  year         = {2023},
  url          = {https://docs.python.org/3/reference/},
}

@incollection{turing1936,
  author       = {Turing, Alan M.},
  title        = {On Computable Numbers, with an Application to the Entscheidungsproblem},
  booktitle    = {Computability: Turing, Gödel, Church},
  editor       = {Herken, Rolf},
  publisher    = {Springer},
  year         = {1988},
  pages        = {116--151},
  note         = {Originally published in 1936},
}

Hello @talb,

uses Hayagriva as its bibliography file format. To my knowledge, all BibTeX entries are internally converted to this format.
interop.rs contains a list of mappings, but I think it is easier to just use Hayagriva to convert the BibTeX entries, which results in:

dirac1930:
  type: chapter
  title: The Principles of Quantum Mechanics
  author: Dirac, Paul A. M.
  date: 1930
  chapter: 3
  page-range: 50-75
  parent:
    type: book
    publisher: Oxford University Press
sampleBooklet:
  type: misc
  title: Quick Reference Guide to Linux Commands
  author: Smith, Jane
  date: 2021
  note: Available online at https://example.com/linux-guide
pythonManual:
  type: reference
  title: Python Language Reference, Version 3.11
  date: 2023
  organization: Python Software Foundation
  url: https://docs.python.org/3/reference/
turing1936:
  type: anthos
  title: On Computable Numbers, with an Application to the Entscheidungsproblem
  author: Turing, Alan M.
  date: 1988
  editor: Herken, Rolf
  page-range: 116-151
  note: Originally published in 1936
  parent:
    type: anthology
    title: 'Computability: Turing, Gödel, Church'
    publisher: Springer
BibTeX type Pandoc’s CSL type Hayagriva type (Typst)
@inbook chapter chapter
@booklet pamphlet misc
@manual book reference
@incollection chapter anthology

Unfortunately, I don’t know why chapter is not recognized by the CSL.

1 Like

Okay, I just checked, with @dirac1930 in Hayagriva style it gets recognized as chapter in CSL, but I don’t know why it doesn’t work with BibTeX.

Thanks @flokl for all this information. However, my problem still stands. Are you able to reproduce the bug of my first message?

Yes, I was able to reproduce it. I also tried to compile with the newest (unreleased) Typst version and there the issue does not appear.

Edit: #361 fixed the issue

Well let’s wait for the next Typst release then! On another note, I’m not entirely sure that the Hayagriva types can be used in the CSL. chapter happens to be both a CSL and Hayagriva type, but I don’t think that misc, reference, or anthology are valid CSL types according to the official CSL documentation: CSL 1.0.2 Specification — Citation Style Language 1.0.1-dev documentation