Closed QaidVoid closed 7 months ago
TLDR: I can reproduce this issue.
Long version:
I added these stanzas to the end of assets/files/works.bib
@misc{book_has_author,
title = {Book Title of Has Author},
url = {https://www.opentextbooks.org.hk/ditatopic/25323},
language = {en},
urldate = {2023-11-24},
journal = {Open Textbooks for Hong Kong},
author = {Strong, Edward},
date = {2016-01-19},
}
@misc{book_no_author,
title = {Book Title of No Author},
url = {https://www.opentextbooks.org.hk/ditatopic/25323},
language = {en},
urldate = {2023-11-24},
journal = {Open Textbooks for Hong Kong},
date = {2016-01-19},
}
and ran the test in tests/typ/meta/bibliography.typ with new test cases:
---
== Missing elements APA
See @book_has_author, @book_no_author.
#bibliography("/files/works.bib", style:"apa")
---
== Missing elements APS
See @book_has_author, @book_no_author.
#bibliography("/files/works.bib", style:"american-physics-society")
---
== Missing elements IEEE
See @book_has_author, @book_no_author.
#bibliography("/files/works.bib", style:"ieee")
The APA style reproduced this issue. I'm not sure of the APS style (may need to look up the APS style guide, but haven't got the time). The IEEE style can correctly display both items: one with and one without author.
Given that some style works and some doesn't, it appears the bug lies in the CSL data that configures the citation/bibliography formats, not in Typst or Hayagriva code themselves.
(I'm not claiming this issue; others feel free to take a crack at it)
Given that some style works and some doesn't, it appears the bug lies in the CSL data that configures the citation/bibliography formats, not in Typst or Hayagriva code themselves.
I don't think the bug lies in the .csl
style. The following are outputted from Zotero's style editor with imported .bib data as well as the APA CSL style. Both entries are as expexted.
It looks to be a problem with the substitue
implementation.
Thanks! Given that it's not in components as high as Typst and Hayagriva, and not in components as low as CSL files, it seems to be in the intermediate citationberg @reknih ?
Specifically https://github.com/typst/citationberg/blob/main/src/lib.rs#L2174-L2175 mentioned cs:substitute
.
/// Possible children for a `cs:names` element.
#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub enum NamesChild {
/// A `cs:name` element.
Name(Name),
/// A `cs:et-al` element.
EtAl(EtAl),
/// A `cs:label` element.
Label(VariablelessLabel),
/// A `cs:substitute` element.
Substitute(Substitute),
}
(but it still baffles me because this issue only manifests for some citation styles)
Do you happen to have any news on this? This is specifically a problem for online resources that often do not have an author.
Thanks! Given that it's not in components as high as Typst and Hayagriva, and not in components as low as CSL files, it seems to be in the intermediate citationberg @reknih ?
Specifically
main
/src/lib.rs#L2174-L2175 mentionedcs:substitute
./// Possible children for a `cs:names` element. #[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize)] #[serde(rename_all = "kebab-case")] pub enum NamesChild { /// A `cs:name` element. Name(Name), /// A `cs:et-al` element. EtAl(EtAl), /// A `cs:label` element. Label(VariablelessLabel), /// A `cs:substitute` element. Substitute(Substitute), }
(but it still baffles me because this issue only manifests for some citation styles)
Yes, substitution doesn't work as intended. If we have the following:
@online{someKey,
title = {Some Title},
url = {https://google.com},
urldate = {2024-03-11},
}
Then it will produce:
Retrieved March 11, 2024, from https://google.com/
As soon as I add an editor or author...
@online{someKey,
editor = {Mustermann, Max},
title = {Some Title},
url = {https://google.com},
urldate = {2024-03-11},
}
...it will produce the following:
Mustermann, M. (Ed.). Some Title. Retrieved March 11, 2024, from https://google.com/
For the APA 7th edition, maybe the choose
is not handled correctly (https://github.com/citation-style-language/styles/blob/0a035d78a6e922f392ccb6af8a6972e5302e02bb/apa.csl#L131-L149 and https://github.com/citation-style-language/styles/blob/0a035d78a6e922f392ccb6af8a6972e5302e02bb/apa.csl#L163-L173)?
I found the problem is due to substitute
and choose
working together. (Its actually a problem of typst/hayagriva
)
substitute
will cause any subsequent query
to variables, in this case, the title
, suppressed if that variable is queried once before.choose
actually calls query
to title
two times, the first time to find out which branch makes sense and the second to render. A simple fix can be to do a silent lookup on the first query
of choose
, much like what is done in Text::will_have_info(..)
.
This is the output from OP's bib after applying the fix:
Definition and objectives of systems development. (2016, January 19). https://www.opentextbooks.org.hk/ditatopic/25323
However, the journal
part does not seem to be there, which I think is not there even with author specified in the first place.
Description
When using references without authors, the generated output format is incorrect.
Example bib,
Expected Citation Output: (Definition and objectives of systems development, 2016)
Actual Citation Output: (2016)
Expected Bibliography Output: Definition and Objectives of Systems Development. (2016, January 19). Open Textbooks for Hong Kong. https://www.opentextbooks.org.hk/ditatopic/25323
Actual Bibliography Output: (2016, January 19). https://www.opentextbooks.org.hk/ditatopic/25323
Reproduction URL
No response
Operating system
Linux
Typst version