typst / citationberg

A library for parsing CSL styles.
Apache License 2.0
33 stars 7 forks source link

Subsequent citation fallback behavior #10

Closed AstrickHarren closed 5 months ago

AstrickHarren commented 6 months ago

Related to typst/hayagriva#141 which is in turn related typst/typst#3699.

The bug seems to be because the citation try to be different in the first and subsequent cases. See https://github.com/typst/citationberg/blob/778a5da601c615960e2dbe2153a33cd2c09ab1a8/src/lib.rs#L2450-L2467

However, self.et_al_subsequent_min and/or self.et_al_subsequent_use_first may be None, resulting in citationberg never suppresses authors. Hence the typst bug.

I purpose the following change:

let (et_al_min, et_al_use_first) = if is_subsequent { 
-     (self.et_al_subsequent_min, self.et_al_subsequent_use_first) 
+     (self.et_al_subsequent_min.or(self.et_al_min), self.et_al_subsequent_use_first.or(self.et_al_use_first)
} else { 
      (self.et_al_min, self.et_al_use_first) 
}; 

If dev would agree, I can potentially open PR and/or add testings. @reknih