Skip to content

Keep WordPress shortcodes out of derived excerpts - #211

Merged
ssavutu merged 1 commit into
mainfrom
fix/shortcode-excerpts
Aug 7, 2026
Merged

Keep WordPress shortcodes out of derived excerpts#211
ssavutu merged 1 commit into
mainfrom
fix/shortcode-excerpts

Conversation

@ssavutu

@ssavutu ssavutu commented Aug 7, 2026

Copy link
Copy Markdown
Member

A crossword post's whole body is a single [puzzleme ...] shortcode. deriveExcerpt strips HTML tags, which leaves brackets alone, so the derived excerpt was the shortcode source — basepath, embed ids, attribution markup and all — and the public site printed it under the headline on the Comics & Puzzles listing:

"What's on Tea-V?" — [puzzleme basepath='https://puzzleme.amuselabs.com/pmm/' set='4d204c…' id='dc2b9486' attribution='Made by Coco Li using the online <a href=…>cross word generator</a> from Amuse Labs' type='crossword']

Shortcodes are now dropped before tags are stripped, since attribute values carry HTML of their own (the puzzleme attribution is a link) that would otherwise be torn out from inside the brackets first. Two shapes match, both narrow enough to leave editorial brackets like [sic] and [Editor's note] alone:

  • the shortcodes this corpus carries, named explicitly (puzzleme, caption, gallery, embed, playlist, audio, video);
  • any bracketed token carrying attributes, which is what makes it a shortcode rather than prose.

Scope: this governs excerpts derived from here on. Rows that already store a shortcode excerpt are cleared directly, and DrexelTriangle/Scalene#77 strips on render so nothing else in the corpus can leak the same way.

Tests: four deriveExcerpt cases for the shortcode shapes plus one asserting editorial brackets survive.

🤖 Generated with Claude Code

A crossword post's whole body is a single [puzzleme ...] shortcode. The
excerpt is derived by stripping HTML tags, which leaves brackets alone,
so the derived excerpt was the shortcode source -- basepath, embed ids,
attribution markup and all -- and the public site printed it under the
headline on the Comics & Puzzles listing.

Drop shortcodes before stripping tags, since attribute values carry HTML
of their own (the puzzleme attribution is a link) that would otherwise be
torn out from inside the brackets first. Two shapes are matched, both
narrow enough to leave editorial brackets like "[sic]" and "[Editor's
note]" alone: the shortcodes this corpus actually carries, named
explicitly, and any bracketed token carrying attributes.

This only governs excerpts derived from here on; rows already storing a
shortcode excerpt are cleared separately, and Scalene strips on render.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ssavutu
ssavutu merged commit de2fe00 into main Aug 7, 2026
6 checks passed
@ssavutu
ssavutu deleted the fix/shortcode-excerpts branch August 7, 2026 20:50
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