Skip to content

Drop the period citeproc-php adds after a "?" or "!" title - #155

Open
dknauss wants to merge 2 commits into
mainfrom
fix/chicago-terminal-punctuation
Open

dknauss wants to merge 2 commits into
mainfrom
fix/chicago-terminal-punctuation

Conversation

@dknauss

@dknauss dknauss commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Problem

The server formatter (citeproc-php, behind bibliography_builder_format_csl_items() and bibliography_builder_write_prepare_entries()) puts a period inside the closing quote after a title that already ends in ? or !:

  • webpage: “What Are Reduced Penetrance and Variable Expressivity?.” MedlinePlus. …
  • article-journal: Moss, Ann. “Diabetes Technology: What’s New in 2025?.” Diabetes Care 48 …

CMOS wants “…?” with no added period. The 2026-10-14 cmt.blog citation pass hit this on three Sources entries (posts 94341, 3766, 606), which were corrected by hand.

Cause

The stray period comes from citeproc-php itself, not from the plugin's en-US "move the period inside the quotes" swap. Rendering a ? title raw with Chicago gives “What Is It?.”: citeproc-php moves the title's . suffix inside the quote without checking for terminal punctuation. It affects every style that quotes titles and ends the title with a period: Chicago notes-bibliography, Chicago author-date and MLA 9. APA, Harvard, IEEE, Vancouver, OSCOLA and ABNT were already correct.

Fix

bibliography_builder_normalize_formatted_text() now removes a period that follows ? or !, with or without a closing ”/’. Commas are left alone: CMOS keeps a comma after a question-mark title (“Are You a Doctor?,”), and IEEE's “…?,” is unchanged.

Tests (test-first)

  • New CslStyleGoldenTest::test_title_ending_in_question_or_exclamation_mark_takes_no_period. It covers a webpage and an article-journal ending in ? and a webpage ending in !, with exact expected strings for Chicago notes-bibliography and MLA 9. It also asserts that no bundled style emits ?./!.. Before the fix it failed with the ?.” output above.
  • The existing CSL style goldens pass byte for byte. No tests/fixtures/csl-styles/*.txt file changed, because the corpus has no ?/! titles, so the CMOS 18 et-al. output (first three authors + et al. for 7+) is untouched.
  • Full PHP suite: 447 tests passing. phpcs is clean on the changed files.

Editor (citeproc-js) path

The editor has no client-side citeproc. src/lib/formatting/csl.js posts the CSL items to the plugin's format REST endpoint, which uses this same PHP formatter, so the fix applies in the editor too. citeproc-js (citeproc 2.4.63) is only a dev dependency, used by src/lib/__test-utils__/citeproc-runner.js for sort conformance. I ran the same three items through it with the packaged Chicago NB, Chicago AD and MLA styles. It already renders “…Expressivity?” MedlinePlus. …, “…What’s New in 2025?” Diabetes Care 48 (2025): 1–10. and “Stop the Presses!” Site. …, and the PHP output now matches it character for character.

Not covered

Bibliographies saved earlier keep the stored ?.” text until they are reformatted or saved again.

🤖 Generated with Claude Code

dknauss and others added 2 commits October 14, 2026 22:38
citeproc-php moves a title's "." suffix inside the closing quote without
checking for terminal punctuation, so Chicago (both styles) and MLA
rendered "What Is It?.”". Strip a period that follows "?" or "!" (with
or without a closing quote) in the formatter's text normalization.
Commas are kept, as CMOS allows after a question-mark title.

citeproc-js already renders these titles correctly; the server output
now matches it. Existing style goldens are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant