typst / hayagriva

Rusty bibliography management.
Apache License 2.0
347 stars 54 forks source link

Support for Citeproc bibliography tests #229

Open Drodt opened 1 month ago

Drodt commented 1 month ago

Currently, all tests of the citeproc test suite that test the bibliography are ignored. Many important features are therefore untested. This should either be fixed or (if there are some issues I am unaware of) a comparable test suite for hayagriva should be build.

Are there any problems preventing support for Bibliography mode?

reknih commented 1 month ago

I have not enabled bibliography tests because they are yielded as HTML:

Note that in bibliography mode, the HTML string output used for testing will be affixed with a standard set of wrapper tags, which must be written into the result string used for comparison:

>>===== RESULT =====>>
<div class="csl-bib-body">
 <div class="csl-entry">J. Noakes, J. Doe, J. Roe (2005)</div>
 <div class="csl-entry">R. Stoakes (1898)</div>
</div>
<<===== RESULT =====<<

We do support formatting citations as HTML, but not exact string matches with citeproc.js. For example, we do not attach the csl-bib-body or csl-entry classes around entries, and neither do we do the same indentation / pretty printing. To use the bibliography mode tests, we'd need to do a combination of fuzzy matching (i.e. ignore more than one whitespace between tags) and adding the citeproc.js classes. I did not feel that that was worth the effort at the time when I added CSL tests but that calculus may have shifted in favor of having test cases now.

Drodt commented 1 month ago

I am not all too familiar with the HTML output by citeproc. Would it make sense to extract the content of each csl-entry <div> and compare the content with each item of hayagriva's output?

reknih commented 1 month ago

The problem is that citeproc may yield additional HTML elements based on the value of the CSL display attribute

reknih commented 1 month ago

If we deep-extracted all text from both data models, it could work