Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .wordpress-org/blueprints/blueprint.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- **Repeated authors setting.** A new block setting, "Repeated authors" (`repeatedAuthorMark`), chooses how an entry by the same authors as the entry before it begins. MLA 9 and OSCOLA 5 blocks can write the names out instead of using their marks; Chicago blocks can use the 17th edition's 3-em dash (`———.`), and ABNT blocks NBR 6023:2002's underscore line (`______.`), for writers and journals that still ask for them. Screen readers hear the names, and copied text and exports keep them. Existing blocks save exactly as before. The write routes' settings `PATCH`, the read routes, the abilities, and `wp borges list` carry the setting. ([#242](https://github.com/dknauss/Borges/issues/242))
- **Harvard citations can be pasted as text.** A Harvard reference with no DOI or other identifier, in the Cite Them Right form Borges's Harvard style prints, is now read into its fields: journal articles, books (with edition and place), chapters in edited books, conference papers, arXiv preprints, encyclopedia entries, and web pages with or without an author, along with their `Available at:` links and access dates. Before, every Harvard reference got the "Paste a DOI…" notice. Pasting into a Harvard bibliography tries the Harvard reading first; in other styles it is tried after the others, so APA citations (with a full stop after the year) are read as before. Like APA, these show "Check the fields before publishing" under the entry. ([#231](https://github.com/dknauss/Borges/issues/231))

### Changed

- **Clearer "Citations in this post" panel.** It now says "in-text citations", "out of date with the current style or numbering", and "edited by hand" instead of code-side terms; with no citations yet it says where Cite is (the block toolbar's More menu); and the checkbox, now "Also update citations I edited by hand", says that your wording will be replaced. The update notice says "hand-edited" to match. ([#269](https://github.com/dknauss/Borges/pull/269))

### Fixed

- **Pasted citations the editor can't read are turned away instead of read wrongly.** A labelled journal article in IEEE, ABNT, or MLA form ("vol. 12, no. 3, pp. 34–43") pasted with no DOI was read as a book, with the volume and issue in its title and the page range as its publisher. It now gets the "Paste a DOI…" notice, as other citations the editor doesn't read do. A numbered entry ("[1] …", "12. …") is read without its number, which used to end up in the first author's name. Citations read by the parser's less certain patterns (chapters, web pages, APA-style books and articles, and articles with "et al." or semicolon-separated authors) now show "Read from pasted text without an identifier. Check the fields before publishing." under the entry and count toward the import notice's "Review N imported records"; editing the entry's fields clears it. ([#231](https://github.com/dknauss/Borges/issues/231))
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Editor-time PMID and formatting results are cached in the object cache and in sh
- **In-text and margin citations** — A **Cite** control in any paragraph (including a theme's margin-note style) links a short citation, such as "Illich, *Tools for Conviviality*, 12", "(Illich 1973, 12)", or "[2]", to its entry in a bibliography on the same post. It is a plain anchor link, so it works without JavaScript. After a style change, **Update citations** rewrites them in the new style, keeping each page number.
- **Structured editing** — Per-field editing for every citation, whatever its source, plus a plain-text override for the displayed line.
- **Annotated bibliographies** — Add your own note to any entry (stored in its CSL `annote`) and turn on "Show annotations" to print the notes under their entries. Annotations travel with CSL-JSON, BibTeX, BibLaTeX, and RIS exports and imports.
- **Repeated authors** — MLA 9's three hyphens and OSCOLA 5's double em dash apply by default. The "Repeated authors" setting can write the names out instead, or bring back Chicago 17's 3-em dash or ABNT's pre-2018 underscore line; screen readers always hear the names.
- **Semantic output** — `role="doc-bibliography"`, `lang` attributes, and hanging-indent styling without deprecated bibliography-entry ARIA roles.
- **JSON-LD** — Schema.org structured data for search engines, AI systems, and semantic consumers (on by default). The cited works are nested in one `ItemList`, so none is mistaken for the page itself.
- **Microformats** — Each entry is an `h-cite` with its title, authors, date, DOI, URL, and container, so IndieWeb tools read the bibliography as citations. Added as the page renders; the `bibliography_builder_enrich_microformats` filter turns it off.
Expand Down
16 changes: 16 additions & 0 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ OSCOLA bibliographies that hold primary sources are saved as OSCOLA 5's tables:
"type": "boolean",
"default": false
},
"repeatedAuthorMark": {
"type": "string",
"enum": [ "style", "dash", "underscore", "none" ],
"default": "style"
},
"citations": {
"type": "array",
"default": [],
Expand Down Expand Up @@ -1051,6 +1056,17 @@ The inline and margin citation format shipped (see [In-Text and Margin Citations
- **Keeping citations current automatically.** **Update citations** (see [Updating citations](#updating-citations)) is run by hand or from the notice after a style change. It could also be offered after an entry is edited or a numeric list is reordered, and the editor could mark a citation whose `ref-…` target is gone.
- **Fuller short forms.** Year suffixes (2020a) in author-date styles, APA's "&" and comma ("(Smith & Jones, 2020)"), a locator label ("p.") per style, and ibid.-free consecutive-note handling.

### Repeated-Author Mark (implemented, 1.20.0)

Some writers, editors, and journals still want the mark an earlier edition of their style used for an entry by the same authors as the one before it; others find any mark unclear. A block setting, **Repeated authors** (`repeatedAuthorMark`, string, default `style`), chooses ([#242](https://github.com/dknauss/Borges/issues/242)).

- **Values:** `style` applies the style's own rule (MLA 9's three hyphens, OSCOLA 5's double em dash, names written out elsewhere); `none` writes names out everywhere; `dash` is Chicago 17's 3-em dash (three U+2014), offered by both Chicago styles; `underscore` is NBR 6023:2002's six underscores, offered by ABNT. Which style offers which is `repeatedAuthorMarks` in `includes/styles.json`, and a mark a style does not offer falls back to `style` (`getRepeatedAuthorRule()` / `bibliography_builder_save_repeated_author_rule()`).
- **Editor:** a select under Citation Style, shown only for a style with a choice (MLA, OSCOLA, Chicago, ABNT; `src/components/repeated-author-mark-control.js`).
- **Output:** the existing repeated-author markup (`bibliography-builder-repeated-author`, the mark `aria-hidden`, the names in `screen-reader-text`) with the chosen mark. Names are matched as strictly as MLA's, written as the bundled Chicago or ABNT CSL writes them. Editors-only entries and titles are never replaced. The PHP port matches the JS; the `*-repeated-author-*` save-parity fixtures pin both.
- **Existing blocks:** an absent setting is `style`, so `save()` writes what 1.19.x wrote and no deprecation is needed. Deprecations ignore the setting (`repeatedAuthorMarkSetting` is passed only by `save.js`).
- **Read model:** `GET …/bibliographies`, the abilities, and `wp borges list --fields=` report `repeatedAuthorMark`; `PATCH …/bibliographies/{ref}` accepts it.
- **Not done:** Chicago 17's `———, ed.` for editors, and NBR 6023:2002's replacement of a repeated title.

### Annotated Bibliographies (implemented)

An annotated bibliography gives each entry a short note of the compiler's own: what the work argues, why it matters, how it was used. It is a long-standing scholarly and teaching genre, and the common hand-built alternative in WordPress (a "reading list" pattern of paragraphs per book) has no metadata, sorting, or export.
Expand Down
5 changes: 5 additions & 0 deletions block.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
"type": "boolean",
"default": false
},
"repeatedAuthorMark": {
"type": "string",
"enum": [ "style", "dash", "underscore", "none" ],
"default": "style"
},
"bibliographyId": {
"type": "string",
"default": ""
Expand Down
7 changes: 6 additions & 1 deletion components.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"source": "block.json",
"design_owner": "Repository source files",
"data_owner": "WordPress editorial content",
"editable": "Declared attributes: citationStyle, headingText, headingLevel, outputJsonLd, outputCoins, outputCslJson, outputCiteExport, showAnnotations, bibliographyId, citations; existing style controls are listed in supports. Attribute declarations are not proof of visible UI controls.",
"editable": "Declared attributes: citationStyle, headingText, headingLevel, outputJsonLd, outputCoins, outputCslJson, outputCiteExport, showAnnotations, repeatedAuthorMark, bibliographyId, citations; existing style controls are listed in supports. Attribute declarations are not proof of visible UI controls.",
"updates": "Saved output remains in post content; existing instances require compatibility/deprecations before markup changes",
"verification": "Source validation plus editor and frontend checks on a local site",
"attributes": {
Expand Down Expand Up @@ -46,6 +46,11 @@
"type": "boolean",
"default": false
},
"repeatedAuthorMark": {
"type": "string",
"enum": [ "style", "dash", "underscore", "none" ],
"default": "style"
},
"bibliographyId": {
"type": "string",
"default": ""
Expand Down
5 changes: 5 additions & 0 deletions docs/csl-styles.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ Deviations shared by every style, all forced by how the block stores and renders

Only the saved bibliography carries the hyphens. The editor's list, copied text, and the exports keep the full names, so each entry still stands on its own.
- **OSCOLA 5 replaces a repeated first author with a double em dash** (§1.7). One author's works come oldest first, then by title within a year, then the works they wrote with others, by co-author; after the first, the first author's name becomes `——` (two U+2014 characters, which wptexturize leaves alone): "—— Punishment and Responsibility (OUP 1968)", with the comma before the title dropped, and "—— and Honoré AM, Causation in the Law (OUP 1959)". `save()` applies it as it does MLA's hyphens, with the name hidden for screen readers, and as strictly: the first authors must match field for field, both entries must start with the name as OSCOLA writes it (family name, with any non-dropping particle, then initials, or a literal name), and a name with a suffix or a dropping particle, or an entry with manual display text, keeps the full name. The dash never crosses from one of OSCOLA's tables to the next. Both rules are switched on per style in `includes/styles.json`: `repeatedAuthors` (`allAuthors` for MLA, `firstAuthor` for OSCOLA) and `chronologicalAuthors` (OSCOLA's date order).
- **A block can choose its repeated-author mark** (`repeatedAuthorMark`, the sidebar's "Repeated authors", since 1.20.0). `style`, the default, applies the rules above. `none` writes every name out, even in MLA and OSCOLA, for readers who find the marks unclear. A style can also offer the mark its earlier edition used, listed in its `repeatedAuthorMarks` in `includes/styles.json`:
- `dash`, for both Chicago styles: the 3-em dash of the 17th edition, saved as three U+2014 em dashes (`———. Labyrinths.`), which run together in nearly every font, unlike U+2E3B. Chicago 18 (§13.72) now prefers repeating the names.
- `underscore`, for ABNT: the line of six underscores and a period (`______. Labyrinths.`) of NBR 6023:2002, which the 2018 revision dropped in favour of repeating the names.

Both replace the whole author list under the same strict rules as MLA's hyphens, with the names written the way the bundled CSL file writes them: Chicago inverts the first author, joins the rest with a comma before "and", and shortens seven or more to three and "et al."; ABNT writes every name as `FAMILY, Given`, separated by semicolons, shortens four or more to the first and "et al.", and skips any name with a particle or suffix, whose capitals the CSL processor decides. An entry with editors and no author keeps its names (Chicago 17's `———, ed.` form is not applied), and the title is never replaced. A mark the style does not offer is ignored, so switching a Chicago block with the dash to APA prints names, and switching it back restores the dash. The setting changes only the saved bibliography; the editor's list, copied text, and exports keep the full names.
- **Chicago keeps no place of publication for pre-1900 books.** The 18th edition still gives a place for books published before 1900, but CSL cannot compare years, so the place is dropped for every book.
- **No citation numbers.** Numeric styles number with the list element.
- **Journal abbreviations come from the record.** IEEE and Vancouver print a journal article's `container-title-short` when it has one (Vancouver without periods, as NLM writes them; citeproc-php ignores `strip-periods`, so `bibliography_builder_format_csl_items()` removes them for a style that asks for it on that element), and the full title otherwise. Borges does not look abbreviations up: they come from CrossRef, PubMed, RIS `J2`, BibLaTeX `shortjournal`, Zotero's `journalAbbreviation`, or the entry editor's "Journal abbreviation" field. Conference proceedings titles are not abbreviated.
Expand Down
4 changes: 2 additions & 2 deletions docs/current-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Source and LOC figures last verified: **2026-10-06** against the heading-level b
| Metric | Value | Re-derivation command |
|---|---|---|
| Main plugin file (`bibliography-builder.php`) | **823** | `wc -l bibliography-builder.php` |
| All first-party PHP (excl. vendor, tests, scripts, playground, packages, output, node_modules, generated `build/`) | **18436** | `find . -name '*.php' -not -path './vendor/*' -not -path './node_modules/*' -not -path './tests/*' -not -path './packages/*' -not -path './scripts/*' -not -path './playground/*' -not -path './output/*' -not -path './build/*' -print0 \| xargs -0 wc -l \| tail -1` |
| JS source (`src/`, excl. `*.test.js`) | **16878** | `find ./src -name '*.js' -not -name '*.test.js' -print0 \| xargs -0 wc -l \| tail -1` |
| All first-party PHP (excl. vendor, tests, scripts, playground, packages, output, node_modules, generated `build/`) | **18634** | `find . -name '*.php' -not -path './vendor/*' -not -path './node_modules/*' -not -path './tests/*' -not -path './packages/*' -not -path './scripts/*' -not -path './playground/*' -not -path './output/*' -not -path './build/*' -print0 \| xargs -0 wc -l \| tail -1` |
| JS source (`src/`, excl. `*.test.js`) | **17222** | `find ./src -name '*.js' -not -name '*.test.js' -print0 \| xargs -0 wc -l \| tail -1` |
| Shipped frontend runtime (`build/view.js`, minified) | **3,183 bytes** | `npm run build` then `wc -c < build/view.js` |

The only PHP that executes at runtime on a visitor request path is `bibliography-builder.php`
Expand Down
3 changes: 2 additions & 1 deletion docs/rest-write-routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ The `changes` object depends on the route:
| `outputCslJson` | boolean | `false` | Output CSL-JSON |
| `outputCiteExport` | boolean | `false` | Per-entry Cite / Export |
| `showAnnotations` | boolean | `false` | Show annotations |
| `repeatedAuthorMark` | string: `style`, `dash`, `underscore`, or `none` | `style` | Repeated authors |

Citations are not touched. An unknown setting or a wrong type gets `400`. A setting sent with its default value is left out of the block comment, as the editor leaves it out. `citationStyle` is refused with `400` (`bibliography_builder_style_needs_reformat`), because changing the style means reformatting every entry. Use `…/reformat` for that.
Citations are not touched. An unknown setting, a wrong type, or a `repeatedAuthorMark` outside its four values gets `400`. A mark the style does not offer (`dash` on an APA block) is stored and ignored, as in the editor (see [`docs/csl-styles.md`](./csl-styles.md)). A setting sent with its default value is left out of the block comment, as the editor leaves it out. `citationStyle` is refused with `400` (`bibliography_builder_style_needs_reformat`), because changing the style means reformatting every entry. Use `…/reformat` for that.

### Reformatting

Expand Down
2 changes: 1 addition & 1 deletion docs/wp-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The code is in `includes/cli.php` (helpers that return data) and `includes/class

## `wp borges list <post-id>`

One row per bibliography block in the post: `index`, `bibliographyId`, `citationStyle`, `entryCount`, and `headingText`. `--fields=` can add `headingLevel`, `outputJsonLd`, `outputCoins`, `outputCslJson`, and `showAnnotations`. `--format=` is `table` (default), `json`, `csv`, `yaml`, or `count`.
One row per bibliography block in the post: `index`, `bibliographyId`, `citationStyle`, `entryCount`, and `headingText`. `--fields=` can add `headingLevel`, `outputJsonLd`, `outputCoins`, `outputCslJson`, `showAnnotations`, and `repeatedAuthorMark`. `--format=` is `table` (default), `json`, `csv`, `yaml`, or `count`.

```
$ wp borges list 42
Expand Down
24 changes: 15 additions & 9 deletions includes/block-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,34 @@ function bibliography_builder_collect_blocks( $blocks, $results = array() ) {
$attrs = isset( $block['attrs'] ) && is_array( $block['attrs'] ) ? $block['attrs'] : array();

$results[] = array(
'bibliographyId' => bibliography_builder_get_stable_block_id( $attrs ),
'citationStyle' => isset( $attrs['citationStyle'] )
'bibliographyId' => bibliography_builder_get_stable_block_id( $attrs ),
'citationStyle' => isset( $attrs['citationStyle'] )
? (string) $attrs['citationStyle']
: bibliography_builder_default_style_key(),
'headingText' => isset( $attrs['headingText'] )
'headingText' => isset( $attrs['headingText'] )
? (string) $attrs['headingText']
: '',
// The level save() prints: "h3" gives 3, and "p" gives 0.
'headingLevel' => (int) substr(
'headingLevel' => (int) substr(
bibliography_builder_save_heading_tag(
isset( $attrs['headingLevel'] ) ? $attrs['headingLevel'] : 0
),
1
),
'outputJsonLd' => isset( $attrs['outputJsonLd'] ) ? (bool) $attrs['outputJsonLd'] : true,
'outputCoins' => ! empty( $attrs['outputCoins'] ),
'outputCslJson' => ! empty( $attrs['outputCslJson'] ),
'outputJsonLd' => isset( $attrs['outputJsonLd'] ) ? (bool) $attrs['outputJsonLd'] : true,
'outputCoins' => ! empty( $attrs['outputCoins'] ),
'outputCslJson' => ! empty( $attrs['outputCslJson'] ),
// Whether save() prints annotations (CSL `annote`). The CSL-JSON
// keeps them either way; the plain text, like the editor's
// "Copy bibliography", leaves them out.
'showAnnotations' => ! empty( $attrs['showAnnotations'] ),
'citations' => isset( $attrs['citations'] )
'showAnnotations' => ! empty( $attrs['showAnnotations'] ),
// How save() marks a repeated author (1.20.0): `style` unless
// the block chose `dash`, `underscore`, or `none`.
'repeatedAuthorMark' => isset( $attrs['repeatedAuthorMark'] )
&& is_string( $attrs['repeatedAuthorMark'] )
? $attrs['repeatedAuthorMark']
: 'style',
'citations' => isset( $attrs['citations'] )
&& is_array( $attrs['citations'] )
? array_values(
array_filter( $attrs['citations'], 'is_array' )
Expand Down
3 changes: 2 additions & 1 deletion includes/class-bibliography-builder-cli-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ final class Bibliography_Builder_CLI_Command {
* : Post ID.
*
* [--fields=<fields>]
* : Columns to show. Also available: headingLevel, outputJsonLd, outputCoins, outputCslJson, showAnnotations.
* : Columns to show. Also available: headingLevel, outputJsonLd, outputCoins, outputCslJson, showAnnotations,
* repeatedAuthorMark.
*
* [--format=<format>]
* : Output format.
Expand Down
Loading
Loading