Skip to content

Keep bibliography JSON-LD, CSL-JSON and Cite / Export labels out of Jetpack Search #290

Open

Description

@dknauss

Problem

On counterfoil.org, Jetpack Search result excerpts show raw bibliography data instead of prose, for example:

"author":[{"@type":"Person","name":"Ivan Illich","familyName":"Illich","givenName":"Ivan"}],"datePublished":"1974"

and "Cite / Export Copy citation RIS CSL-JSON BibTeX BibLaTeX". On 2026-11-11, 34 of 39 results for "Ivan" had JSON in their content highlights (checked through GET https://public-api.wordpress.com/rest/v1.3/sites/224059621/search?query=Ivan&highlight_fields[0]=content).

The bibliography block saves its JSON-LD and CSL-JSON as <script> elements in post_content, and Jetpack's indexer keeps the text inside <script> elements. Some of the indexed JSON is in the pre-1.11 array form ([{"@context"...), which only exists in raw post_content, so the indexer reads the raw content and not only the rendered copy. Every Borges site that runs Jetpack Search will hit this until Jetpack stops indexing script text.

Proposal

Borges already cleans its markup for feeds and email (includes/email-output.php). The Jetpack Sync payload needs the same kind of cleanup:

  • Strip <script type="application/ld+json"> and <script type="application/vnd.citationstyles.csl+json"> from inside .wp-block-bibliography-builder-bibliography, along with details.bibliography-builder-cite-export.
  • Strip them only from cloned posts in the jetpack_sync_before_enqueue_jetpack_sync_save_post, jetpack_sync_before_enqueue_jetpack_published_post and jetpack_sync_before_send_jetpack_full_sync_posts filters, at priority 20 so it runs after Jetpack has added post_content_filtered. The stored post and the rendered page, including the structured data search engines read, stay as they are.
  • On upgrade, when Jetpack is active, request one full sync of posts with Automattic\Jetpack\Sync\Actions::do_full_sync( array( 'posts' => true ) ) so content that is already indexed gets cleaned.

The Counterfoil theme carries a site-level version of this in dknauss/counterfoil#43 (clean_synced_posts() in themes/counterfoil/functions.php). Once Borges ships the fix, that copy can go.

Not recommended for now: emitting the JSON-LD at render time instead of in save(). That would break the readme's "static HTML, no render callback" promise and need another block deprecation.

Activity

  1. dknauss commented on Nov 11, 2026

    @dknauss
    OwnerAuthor

    Upstream report: Automattic/jetpack#54779 (Jetpack Search indexes the text inside <script> elements). If Jetpack fixes it, this Borges workaround becomes optional.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions