Skip to content

Give OSCOLA its own short form and work out note positions - #326

Merged
dknauss merged 2 commits into
mainfrom
claude/project-thread-cipila
Nov 30, 2026
Merged

dknauss merged 2 commits into
mainfrom
claude/project-thread-cipila

Conversation

@dknauss

@dknauss dknauss commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Requested by Dan · project thread

Summary

PR 1 of the note citations build for #243, following docs/planning/note-citations-plan.md (tickets N2.4 and N2.3). Later PRs: 2, the Chicago and OSCOLA <citation> layouts and the /format layout parameter (N2.1, N2.2); 3, Cite as a core footnote and Update citations over the footnotes meta (N2.5 to N2.7); 4, write routes, CLI, and the Chicago ibid. option (Phase 3).

What changed

  • OSCOLA short form (N2.4). Cite gave OSCOLA the Chicago short note (Hart, *The Concept of Law*, 135). OSCOLA now gets Hart 135. The pinpoint goes after a space, with no comma, and a leading p./pp. is dropped. Names are joined OSCOLA's way: A and B, A, B and C, and A and others for more than three. A case is cited by its italic name, using title-short when the record has one. An Act or instrument is cited by its title and year, with a comma before the section: Human Rights Act 1998, s 6. Given a first-note number, the form adds OSCOLA 5's (n 1), but never for legislation or treaties.
  • includes/styles.json gains an optional shortForm key ("oscola"), read by the new getShortFormKind(). StyleDataTest allows it and checks it.
  • Update citations. Old OSCOLA citations in the Chicago form still count as generated, so an update rewrites them. The new form counts as generated too. A bare surname with no locator counts only in an OSCOLA bibliography, so a name linked by hand in APA ("as Hart argues") is still left alone. The OSCOLA form is never used to recover a legacy locator.
  • Note positions (N2.3). src/lib/note-positions.js works out first, subsequent, and opt-in ibid. positions in note order, along with each work's first-note number. It is pure and unused until PR 3, so a PHP port can share its fixtures.
  • Demo. The Playground OSCOLA example gets a paragraph that cites four of its sources. A new test in src/playground-demo.test.js checks that every demo citation is in its current short form.
  • SPEC.md (Short form, Updating citations) and CHANGELOG (Unreleased, Fixed) are updated.

Why: the plan makes OSCOLA's own short form a prerequisite for OSCOLA notes, and the Stage 1 form was wrong for OSCOLA in the text as well.

save() is unchanged, so no deprecation is involved.

Validation

  • npm run lint:js passes
  • npm run lint:css: no CSS changed
  • npm run lint:i18n: no source strings changed
  • npm run test passes (1,741 tests); npm run typecheck:js and npm run format:check pass
  • npm run build succeeds
  • PHPUnit (894 tests) and composer lint:php pass
  • Tested in the block editor: not yet; the demo's OSCOLA paragraph is the place to try it

Checklist


Generated by Claude Code

Note citations, PR 1 of the #243 build (plan tickets N2.4 and N2.3).

Cite gave OSCOLA the Chicago short note. OSCOLA now gets its own form,
"Hart 135": surname, pinpoint after a space with no comma or "p.",
OSCOLA's name joining, cases by italic name, Acts and instruments by
title and year with a comma before the section. With a first-note
number it carries OSCOLA 5's cross-reference, "Hart (n 1) 140".

styles.json gains an optional `shortForm` key ("oscola"), read by
getShortFormKind(). Update citations counts the old Chicago form and the
new OSCOLA form as generated, but a bare surname only in an OSCOLA
bibliography, and never recovers a legacy locator from the OSCOLA form.

src/lib/note-positions.js works out first, subsequent, and (opt-in)
ibid. positions in note order, with the number of each work's first
note, ready for footnote citations.

The Playground OSCOLA example adds a paragraph citing four sources, and
a demo test checks every demo citation is in its current short form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WPtgA26bGmxnWFaShGz2hk
@dknauss dknauss self-assigned this Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Plugin readme preview

Open preview · Commit ddc2c87

37 passed · 0 warnings · 0 notes

Passed checks (37)
  • 145 / 150 characters in the short description.
  • Plugin name header recognized.
  • License header recognized: GPLv2 or later.
  • 5 tags accepted within the five-tag limit.
  • Description is within the parser’s word limit.
  • Installation is within the parser’s word limit.
  • Faq is within the parser’s word limit.
  • Changelog is within the parser’s word limit.
  • Tested up to 7.1, the latest WordPress major release.
  • Stable tag is declared: 1.23.0.
  • The PHP Version header is declared: 1.23.0.
  • Stable tag matches the PHP Version header: 1.23.0.
  • The readme “Requires at least” value is valid: 6.4.
  • The PHP “Requires at least” header is a numeric version: 6.4.
  • “Requires at least” matches between the readme and PHP header: 6.4.
  • The readme “Requires PHP” value is valid: 8.1.
  • The PHP “Requires PHP” header is a numeric version: 8.1.
  • “Requires PHP” matches between the readme and PHP header: 8.1.
  • “Tested up to” 7.1 meets the minimum WordPress version 6.4.
  • Installation content is present.
  • FAQ content is present.
  • Changelog content is present.
  • Screenshot captions are present.
  • The first changelog release matches Stable tag: 1.23.0.
  • The first changelog release matches PHP Version: 1.23.0.
  • Banner image loaded.
  • Plugin icon loaded.
  • Screenshot 1 has a matching image and caption.
  • Screenshot 2 has a matching image and caption.
  • Screenshot 3 has a matching image and caption.
  • Screenshot 4 has a matching image and caption.
  • Screenshot 5 has a matching image and caption.
  • Screenshot 6 has a matching image and caption.
  • Screenshot 7 has a matching image and caption.
  • Screenshot 8 has a matching image and caption.
  • Screenshot 9 has a matching image and caption.
  • Plugin PHP header loaded.

Readme and PHP-header checks only; this does not test plugin runtime compatibility.

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

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.86486% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.30%. Comparing base (82e28e5) to head (ddc2c87).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/lib/citation-short-form.js 61.90% 0 Missing and 16 partials ⚠️
src/lib/note-positions.js 72.00% 0 Missing and 7 partials ⚠️
src/lib/citation-update.js 57.14% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #326      +/-   ##
============================================
- Coverage     87.41%   87.30%   -0.12%     
  Complexity       67       67              
============================================
  Files           113      114       +1     
  Lines         12807    12875      +68     
  Branches       1348     1373      +25     
============================================
+ Hits          11195    11240      +45     
  Misses          489      489              
- Partials       1123     1146      +23     

☔ 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 November 30, 2026 05:11
@dknauss
dknauss merged commit 90abd89 into main Nov 30, 2026
25 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-30T05:11:13.615039Z
We couldn’t complete this review. Comment @codex review to try again.
ddc2c87 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dknauss
dknauss deleted the claude/project-thread-cipila branch November 30, 2026 05:11
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

dknauss commented Nov 30, 2026

Copy link
Copy Markdown
Owner Author

Independent post-merge review

I read the merged diff fresh (citation-short-form.js, citation-update.js, note-positions.js, styles.json), focusing on anything that could make Update citations silently rewrite prose. No live bug that rewrites user text today. The bare-surname gate is sound: classification uses the bibliography's current styleKey, so a hand-linked "Hart" counts as generated only while the bibliography is OSCOLA, where the OSCOLA form is also "Hart", so an update leaves it alone. After a switch to Chicago it becomes reworded and is left alone.

Three things the next PRs (footnote insertion, PR 3) must handle, ranked:

  1. Update citations will strip or ignore (n X) cross-references. isGeneratedText() builds the OSCOLA sample with no firstNote, and getShortFormHtml() never passes firstNote either. Once notes contain "Hart (n 1) 135", Update citations classifies it as reworded. With "replace reworded citations too" turned on, it rewrites it to "Hart 135", dropping the cross-reference. Note renumbering also makes "(n 1)" go stale whenever notes move. The note-aware update path needs getNotePositions() output fed into both classification (accept any (n \d+)) and regeneration (current firstNote).
  2. A repeat citation inside the same note gets firstNote equal to its own note. getNotePositions() marks the second citation of a work in note 3 as subsequent with firstNote: 3, so a consumer would print "Hart (n 3)" inside note 3. Suggest the consumer omits the cross-reference when firstNote === note, or the function exposes that case. Test idea: [{ id: 'a', citations: [{ ref: 'x' }, { ref: 'x' }] }].
  3. Ibid looks only at Borges citations. previousRefs ignores non-Borges text in the previous note, so a note citing work A plus a hand-typed source would still allow "Ibid." for A in the next note. It's off by default and Chicago only, so this is low priority, but worth a doc line on the option.

Nits: getOscolaPinpoint() strips only p./pp., so "p 135" or "page 135" stays as typed (probably fine). A case or statute with no title and no names gives a bare pinpoint as the whole citation.

No regex HTML parsing was added here. findCitationLinks() (pre-existing) scans with a quote-aware tag regex and then hands each tag to the DOM parser, which is the right split in JS; the WordPress HTML API is PHP only, so it would matter only for a future PHP port of Update citations (Phase 3 write routes), where WP_HTML_Tag_Processor would be the right tool for reading data-bibliography-ref and data-locator.


Generated by Claude Code

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.

2 participants