Skip to content

Sort names with particles per each style's demote setting - #147

Merged
dknauss merged 1 commit into
mainfrom
claude/keen-tesla-49orwb
Oct 14, 2026
Merged

dknauss merged 1 commit into
mainfrom
claude/keen-tesla-49orwb

Conversation

@dknauss

@dknauss dknauss commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #142. Before this change, a surname opening with a lowercase particle ("van Duijnhoven", "de la Cruz", "von Neumann", "d'Alembert") sorted under the particle in every style.

Now each bundled style's demote-non-dropping-particle setting decides:

  • Chicago (both styles) and Vancouver sort by the surname proper. For Chicago, the formatter also splits the particle out before citeproc-php renders, so the entry reads "Duijnhoven, Elza van" and sorts under D.
  • APA, MLA, Harvard and the rest keep the particle in front and still sort under V.
  • Capitalized forms ("Van Buren") are part of the surname and are never split.

No data-shape change. Names stay stored as entered, and the particle is worked out at sort and format time. BibTeX/RIS export, JSON-LD, COinS, Edit fields and dedup are unchanged.

New code:

  • src/lib/name-particles.js holds the shared particle rules.
  • The style registry gains demoteNonDroppingParticle.
  • The sorter takes a particleAwareSort option.
  • The PHP save port in includes/save-markup.php mirrors all of it.

Compatibility. save() order changes, so a new deprecated[0] freezes the pre-1.12.0 shape. Existing posts stay valid and take the new order the next time they are saved. The formatter cache key is bumped to version 3.

Validation

  • npm run lint:js, lint:css, lint:i18n: pass
  • composer lint:php, composer analyze:php: pass
  • Jest: 1049 passed, 2 skipped. New tests:
    • name-particles.test.js, including a check that each registry entry matches its bundled CSL file;
    • deprecation fixture v13;
    • sort-coordination cases 14–17;
    • the citeproc-js conformance particle fixtures, now un-excluded.
  • PHPUnit: 440 tests pass (only the known vendor deprecations reported).
    • New tests cover the split, sort_family and prepare_csl_for_formatter.
    • SortCoordinationTest now prepares items the way the formatter does.
    • The save-parity fixtures (collation-mix, mla-repeated-authors) were regenerated from the PHP port, and JS parity is 20/20.
  • npm run build and npm run package:release succeed. composer verify:metrics passes, with the metrics doc updated.

Checklist

  • Tests added/updated
  • CHANGELOG [Unreleased] entry
  • Docs/metrics updated
  • Saved-content compatibility covered by a deprecation

🤖 Generated with Claude Code

https://claude.ai/code/session_01KbVuMPN7YTcV27vwsG3LZ2


Generated by Claude Code

A surname opening with a lowercase particle (van, de la, von, d') sorted
under the particle in every style. Chicago and Vancouver demote the
particle, so they now sort by the surname proper, and the formatter splits
the particle out for display-and-sort styles so citeproc-php renders
"Duijnhoven, Elza van". Other styles keep the particle in front.

Names are stored as entered; the particle is inferred at sort and format
time. save() order changes, so a new deprecation freezes the pre-1.12.0
shape, and the PHP save port, parity fixtures, and sort-coordination
cases are updated to match.

Closes #142

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KbVuMPN7YTcV27vwsG3LZ2
@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.72603% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.88%. Comparing base (b8be70b) to head (7aa36ec).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/lib/name-particles.js 60.00% 0 Missing and 12 partials ⚠️
src/lib/sorter.js 81.25% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #147      +/-   ##
============================================
+ Coverage     87.87%   87.88%   +0.01%     
  Complexity       22       22              
============================================
  Files            59       60       +1     
  Lines          6952     7060     +108     
  Branches        678      690      +12     
============================================
+ Hits           6109     6205      +96     
  Misses          292      292              
- Partials        551      563      +12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dknauss
dknauss marked this pull request as ready for review October 14, 2026 22:21
@dknauss
dknauss merged commit 1aad1b4 into main Oct 14, 2026
19 checks passed
@dknauss
dknauss deleted the claude/keen-tesla-49orwb branch October 14, 2026 22:21
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.

Sort names with particles (van, von, de) by main surname; honour CSL particle fields

2 participants