How to ignore strings in bibliography sorting?

Hello. In my bibliography, I would like the sorting order of authors’ names or titles to ignore certain strings or words: for example, “al-” (a definite article in names transliterated from Arabic to English), “A”, “The”, etc.

Is this currently possible? (I am currently using a Hayagriva .yml file, though would need the same if using a Bibtex file.) Many thanks for any help.

Hello. CSL does support sorting by macro output, so if you can make a macro that can strip articles and stuff, then you can do that. But generally there is no way to replace or remove substring, so it’s not possible with CSL alone.

There is an issue about sorting, if callback sorting will be added, then you can transform the field data how you need and then sort it accordingly.

1 Like

Many thanks for this – now I understand better why it wasn’t working, whatever demote-non-dropping-particle value I was putting.

I don’t unfortunately know anything about macro writing, but I will try to look into it. Thank you again.

1 Like

demote-non-dropping-particle probably should work if used correctly. If not, then it might be a bug in GitHub - typst/hayagriva: Rusty bibliography management..

It might very well work as designed, but isn’t quite doing what I expected. If the particle includes a dash (for example, “al-Ghazali”), the particle “al-” is not ignored. If however the particle does not have contain a dash (“von Humboldt”), the ignore works.

This dash use case is discussed on the CSL 1.02. Spec page under ‘particles’, but alas is not working. I tried it using both Hayagriva and Bibtex files but to no avail.

What is the code you are testing?

rg demote_non shows that this feature is present.

Thanks for your help. Here is a brief sample in Hayagriva’s format:

Summary
tahanawi1996:
  type: Book
  title: "Kashshāf iṣṭilāḥāt al-funūn wa-l-ʿulūm"
  author: al-Tahānawī, Muḥammad ʿAlī
  publisher:
    name: Maktabat Lubnān Nāshirūn
    location: Beirut
  editor: al-ʿAjam, Rafīq
  date: 1996

haydar1991:
  type: Book
  title: "Durar al-ḥukkām fī sharḥ Majallat al-aḥkām"
  author: Ḥaydar, ʿAlī
  publisher:
    name: Dār al-Jīl
    location: Beirut
  date: 1991
  translator: al-Ḥusaynī, Fahmī
  volumes: 4

If the ordering worked, the Ḥaydar work should come first (’H’) followed by al-Tahānawī (‘T’). However, so long as the dash is present (al-), the order is ‘al-Tahānawī’ followed by ‘Ḥaydar’. If you remove the dash (al Tahānawī), it works.

What about the CSL style?

I attach the style I am using. (Please change the file ending from txt to csl.)

chicago-library-list-mod.txt (46.6 KB)

EDIT: The CSL file is apparently too long to go into the post, even when folded away.

You can always use

<details><summary>Summary</summary>
</details>

or native within the gear dropdown menu

[details="Summary"]
[/details]

and insert file content in code block.

I can’t seem to include the file content due to its length, but it is that of the standard Chicago Manual of Style 17th edition (full note) on CSL Githib repo.

Hm, so the limit is 32000 Unicode code points, which translates to a file size from 31.19 KiB to 7.80 KiB, depending on code point length.

Yes, apparently the limit is too small for the CSL file I was copying and pasting. Is there some other way I could share it, to move this forward? Many thanks for your help.

Yeah, I’m not sure how exactly it should work, since for author: van Gogh, Vincent doesn’t move with author: Haydar, ʿAlī when changing the value in all 4 places, so maybe it doesn’t work at all.

Also, author: al-Tahānawī, Muḥammad ʿAlī will never move down under author: Ḥaydar, ʿAlī, because lexographically goes after a or T. I don’t know it if has to be treated like H.

#let bib = ```yaml
tahanawi1996:
  type: Book
  title: "Kashshāf iṣṭilāḥāt al-funūn wa-l-ʿulūm"
  author: al-Tahānawī, Muḥammad ʿAlī
  # author: van Gogh, Vincent
  publisher:
    name: Maktabat Lubnān Nāshirūn
    location: Beirut
  editor: al-ʿAjam, Rafīq
  date: 1996

haydar1991:
  type: Book
  title: "Durar al-ḥukkām fī sharḥ Majallat al-aḥkām"
  # author: Ḥaydar, ʿAlī
  author: Haydar, ʿAlī
  publisher:
    name: Dār al-Jīl
    location: Beirut
  date: 1991
  translator: al-Ḥusaynī, Fahmī
  volumes: 4
```.text

#bibliography(bytes(bib), style: "chicago-library-list-mod.csl", full: true)
// #bibliography(bytes(bib), style: "chicago-library-list.csl", full: true)
// #bibliography(bytes(bib), style: "chicago-author-date", full: true)
// #bibliography(bytes(bib), style: "chicago-fullnotes", full: true)
// #bibliography(bytes(bib), style: "chicago-notes", full: true)

I think the basic mechanism is working, based on “Van Gogh” being filed correctly under ‘G’ in the fuller list below:

Summary
tahanawi1996:
  type: Book
  title: "Kashshāf iṣṭilāḥāt al-funūn wa-l-ʿulūm"
  author: al-Tahānawī, Muḥammad ʿAlī
  publisher:
    name: Maktabat Lubnān Nāshirūn
    location: Beirut
  editor: al-ʿAjam, Rafīq
  date: 1996

vangogh1888:
  type: Book
  title: " The Red Vineyards"
  author: van Gogh, Vincent
  publisher:
    name: Pushkin State Museum of Fine Arts
    location: Moscow
  date: 1888

haydar1991:
  type: Book
  title: "Durar al-ḥukkām fī sharḥ Majallat al-aḥkām"
  author: Ḥaydar, ʿAlī
  publisher:
    name: Dār al-Jīl
    location: Beirut
  date: 1991
  translator: al-Ḥusaynī, Fahmī
  volumes: 4

divan2020:
  type: Book
  title: "The Poem"
  author: Divan, Pastel
  publisher:
    name: Blue Press
    location: Madison
  date: 2000

katibcelebi1941:
  type: Book
  author: Kātib Çelebī, Muṣṭafā
  title: "Kashf al-ẓunūn"
  publisher:
    name: Maarif Matbaasi
    address: Istanbul
  date: 1941
```.text

#bibliography(bytes(bib), style: "chicago-library-list-mod.csl", full: true)
// #bibliography(bytes(bib), style: "chicago-library-list.csl", full: true)
// #bibliography(bytes(bib), style: "chicago-author-date", full: true)
// #bibliography(bytes(bib), style: "chicago-fullnotes", full: true)
// #bibliography(bytes(bib), style: "chicago-notes", full: true)

According to publishing standards in my own fields, the organisation should be:

  • Divan, Pastel
  • van Gogh, Vincent (under G)
  • Ḥaydar, ʿAlī (under H)
  • Kātib Çelebī, Muṣṭafā
  • al-Tahānawī, Muḥammad ʿAlī (under T)

When using code block inside a code block, you need to use more backticks outside, your code snippet is missing first line.

I literally switch between demote-non-dropping-particle="sort-only", demote-non-dropping-particle="never" and none in 4 places and see no change whatsoever.

I don’t see that it works at all.

It appears you are right. Perhaps it should be filed on Github as a new issue.

You can do this in GitHub · Where software is built.