Support CSL test cases that use the CITATIONS section - #501
Open
YDX-2147483647 wants to merge 2 commits into
Open
Support CSL test cases that use the CITATIONS section#501YDX-2147483647 wants to merge 2 commits into
CITATIONS section#501YDX-2147483647 wants to merge 2 commits into
Conversation
YDX-2147483647
marked this pull request as ready for review
July 23, 2026 06:36
YDX-2147483647
force-pushed
the
num
branch
3 times, most recently
from
July 23, 2026 06:47
6256cbd to
f43240e
Compare
Collaborator
|
Thanks! That looks great. Two questions:
|
Contributor
Author
Both options are okay to me. Either you or I will have to resolve merge conflicts. (What I meant was that the relevant code will need further modifications before the next hayagriva release, so it's not the final form. Sorry if there was any ambiguity caused.)
No. This only involves six test cases, and the bugs they may catch look irrelevant to hayagriva. |
Contributor
Author
|
I've updated |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The CSL test suite defines two sections for testing citations:
CITATION-ITEMSandCITATIONS. Only one of them may be used in a single test case1.Previously, only
CITATION-ITEMSwas supported, and all test cases that useCITATIONSwere skipped.I think it's necessary to support
CITATIONS.For example, at present, Typst does not work well with the CSL variable
first-reference-note-number(#500). However, all test cases relevant tofirst-reference-note-numberuseCITATIONS, so they are all skipped.This PR adds support for the
CITATIONSsections by normalizing them intoCITATION-ITEMS.(In most cases,
CITATIONSis just a verbose alternative representation ofCITATION-ITEMS.)42 test cases are affected: 16 skipped → passed, 13 skipped → failed, and 13 are still skipped. Details are shown at the end.
Only tests in the CSL test-suite are normalized; local tests in this repo do not require normalization.
This PR is ready for review, but I guess this won't be the final form.
Drodt is working on restructuring the repo in #489, so it's likely that merge conflicts will occur.
Therefore, I keep most changes in
mod citeproc_js {…}. I hope this will makegit mergeeasier…This PR depends on typst/citationberg#45.(Now merged)Further details
CSL test suite and citeproc.js
CITATION-ITEMSvs.CITATIONSAn example with explanation
Consider the citations in the above Typst document.
CITATION-ITEMSrepresents it as:[ [{ "id": "a" }], [{ "id": "b" }, { "id": "c" }], [{ "id": "d" }] ]And
CITATIONSrepresents it as three invocations to citeproc.jsprocessCitationCluster():[ [ { "citation_id": "CITATION-1", "citation_items": [{ "id": "a" }] }, [], [] ], [ { "citation_id": "CITATION-2", "citation_items": [{ "id": "b" }, { "id": "c" }] }, [["CITATION-1", 0]], [] ], [ { "citation_id": "CITATION-3", "citation_items": [{ "id": "d" }] }, [["CITATION-1", 0], ["CITATION-1", 1]], [] ] ]In some test cases, a citation is first added and then modified in a subsequent invocation.
For example, the above example can also be represented as:
@a.@d.@b @c.[ [ { "citation_id": "CITATION-1", "citation_items": [{ "id": "a" }] }, [], [] ], [ { "citation_id": "CITATION-2", "citation_items": [] }, [["CITATION-1", 0]], [] ], [ { "citation_id": "CITATION-3", "citation_items": [{ "id": "d" }] }, [["CITATION-1", 0], ["CITATION-1", 1]], [] ], [ { "citation_id": "CITATION-2", "citation_items": [{ "id": "b" }, { "id": "c" }] }, [["CITATION-1", 0]], [["CITATION-3", 2]], ] ]For Hayagriva, it is meaningless to test modifications, so it's okay to collect those
citation_itemsand normalizeCITATIONSasCITATION-ITEMS.Citation RESULT
For test cases that use
CITATIONSand in the citation mode, the citeproc.js test runner prepends>>to entries updated in the last citation request, and prepends..to others. It also prepends indicesas
[n](with a trailing space).As a result, we'll see something like this in the
RESULTsection:For Hayagriva, it is also meaningless to test which entries were updated. Therefore, I just trim these prefixes as follows before comparison.
Affected test cases
42 tests are affected. Previously, all of them were skipped.
Skipped → Passed (16 tests)
Skipped → Failed (13 tests)
Manual check shows that these are real failures.
Name (5 tests)
Works by the same author in the same citation group is not collapsed as expected.
For example, expected Fitzpatrick, 2005a, 2005b, but got Fitzpatrick, 2005a; Fitzpatrick, 2005b.
la Berge becomes Berge.
<name form="long"/>is not respected.Position (3 tests)
<if position="…">does not matchibidornear-noteas expected.The term ibid is not capitalized as expected.
Delimiter (5 tests)
The
delimiteron<layout>is applied to the wrong place.For example, John Doe, His Book becomes John Doe; , His Book, where
;is the delimiter on<layout>.Some delimiters are added incorrectly. This case is a bit complicated and I'm not sure about the exact reason.
Cannot normalize (8 tests)
These tests are still skipped, because their
citationsfields are too complicated to be normalized ascitation_items.NonSequentialCitations(6 tests)These test cases are about inserting new citations before existing ones. I don't quite understand the convention of
citationsPreandcitationsPostin this case, so I keep them skipped.["CITATION-1", "CITATION-2"], current ="CITATION-2", pre =[], post =[])["CITATION-1"], current ="CITATION-2", pre =[], post =["CITATION-1"])["CITATION-1", "CITATION-2", "CITATION-3", "CITATION-4"], current ="CITATION-5", pre =[], post =["CITATION-1", "CITATION-2", "CITATION-3", "CITATION-4"])["CITATION-1", "CITATION-2", "CITATION-3"], current ="CITATION-4", pre =["CITATION-1"], post =["CITATION-2", "CITATION-3"])["CITATION-1", "CITATION-2", "CITATION-3"], current ="CITATION-4", pre =[], post =["CITATION-1", "CITATION-2", "CITATION-3"])["CITATION-1"], current ="CITATION-2", pre =[], post =["CITATION-1"])NonSequentialNoteNumbers(2 tests)I can't understand what's going on in these test cases… Keep them skipped for now.
[1, 2, 2], post =[])[1, 1], post =[])MissingResultPrefix(0 test)This error variant is left for trimming the citation result as described above. All test cases match the expectation, so the error is never triggered.
Normalized but still skipped (5 tests)
These tests are still skipped, for reasons other than the
citations→citation_itemsnormalization.(cause: unsupported test feature)
These test cases use affixes in citations.
(cause: HTML suspected in citation result)
These test cases use
<i>,<b>,<span style="font-variant:small-caps;">, or other HTML markups.Footnotes
bugreports_EnvAndUrb is an exception. I believe it's an error and I've reported in
bugreports_EnvAndUrbis malformed: It contains both CITATION-ITEMS and CITATIONS citation-style-language/test-suite#88. ↩