bindings: the footnote signal, which book-pipeline still had its own copy of

`looks_like_footnote_citations` is the function chunkmd's `looks_like_citations`
was ported from, and book-pipeline was still running the Python original at
four call sites. Bound on all four surfaces so it can stop.

Checked against the Python over 34,458 chunks of the live corpus: no
disagreement.
This commit is contained in:
funkpower
2026-09-20 14:44:09 -04:00
parent e896cf4f4f
commit 6aeea58147
8 changed files with 56 additions and 0 deletions
+20
View File
@@ -215,6 +215,14 @@ pub fn parse_identifier(text: &str) -> Option<idnorm::Identifier> {
idnorm::parse(text)
}
/// Whether a chunk of body text carries footnote or endnote citations.
///
/// The structural signal a converter leaves on EPUB3 note definitions first;
/// otherwise the numbered-note markers and what sits after them.
pub fn looks_like_footnote_citations(text: &str) -> bool {
chunkmd::footnote::looks_like_citations(text)
}
/// Read the references out of a bibliography or a page of notes.
///
/// Each carries `unsettled`: the fields that could not be read off the entry,
@@ -261,6 +269,18 @@ mod tests {
assert_eq!(count_tokens("a passage"), textkit::count("a passage"));
}
#[test]
fn the_footnote_signal_agrees_with_the_library_underneath() {
const NOTES: &str = "1. John Smith, *A Title* (Oxford: Clarendon Press, 1998), 183.\n\
2. Jane Doe, *Another* (Cambridge: University Press, 2001), p. 12.";
assert!(looks_like_footnote_citations(NOTES));
assert_eq!(
looks_like_footnote_citations(NOTES),
chunkmd::footnote::looks_like_citations(NOTES)
);
assert!(!looks_like_footnote_citations("Just a paragraph of prose."));
}
#[test]
fn the_citation_surface_agrees_with_the_library_underneath() {
const REFS: &str = "Smith, John. *A Title*. Oxford: Clarendon Press, 1998.\n\nMarron, Kevin Ritual Abuse, Seal Books, 1988";