Formatting: Treat quotes immediately after closing inline tags as closing#12249
Formatting: Treat quotes immediately after closing inline tags as closing#12249dknauss wants to merge 2 commits into
Conversation
…sing. wptexturize() loses word context across an inline HTML tag boundary, so a straight quote or apostrophe immediately after a closing inline element (for example <strong>He</strong>'s or '<a>quoted</a>') is curled as an opening quote. Track whether the preceding text ended in a word, sentence, or closing-quote context, and for a quote immediately following a closing inline tag, classify it as a closing quote or apostrophe. A space before the quote keeps normal opening-quote behavior. Keep the existing tokenizer; do not revive the historical strip/format/reinsert replacement engine (the long-standing performance concern). A fast-path helper keeps the common case off the per-token Unicode-regex path. Add coverage to Tests_Formatting_wpTexturize for the original report's quote-around-inline-HTML cases, the later data_inline_end_tags cases, and the modern apostrophe case from WordPress/gutenberg#42345. Developed with AI assistance (Anthropic Claude via Claude Code, and OpenAI Codex) under maintainer review. See #18549. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: OpenAI Codex <noreply@openai.com>
|
Hi there! 👋 Thank you for your contribution to WordPress! 💖 It looks like this is your first pull request to No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making. More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook. Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook. If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook. The Developer Hub also documents the various coding standards that are followed:
Thank you, |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
| * wptexturize(). Most tokens end with ASCII letters, numbers, or punctuation; only | ||
| * multibyte text and closing quote entities need a regular expression check. | ||
| * | ||
| * @since 7.0.0 |
There was a problem hiding this comment.
Should be either 7.1.0 or if you are unsure when merged a placeholder.
| /** | ||
| * Determines whether a token is a closing tag for a common inline HTML element. | ||
| * | ||
| * @since 7.0.0 |
Trac ticket: https://core.trac.wordpress.org/ticket/18549
What
wptexturize()curls a straight quote/apostrophe to an opening quote when it immediately follows a closing inline tag, because it has lost the word context across the tag boundary:<strong>He</strong>'s here.→…</strong>‘s(should be’s)The word is '<a href="…">quoted</a>'→ trailing‘(should be’)How
Keeps the existing tokenizer and adds a small amount of cross-token state: when a quote token immediately follows a closing inline tag and the preceding text ended in a word/sentence/closing-quote context, the quote is classified as closing. The historical strip/format/reinsert replacement engine is intentionally not revived. A fast-path helper keeps the common case off the per-token Unicode regex.
Scope / deliberate choices
<strong>He</strong> 'go'stays‘go’).kbd(already a no-texturize tag), deprecatedacronym, and]from the trailing-context class (including]changed the existing "crazy" shortcode fixture, so current behavior is preserved).Testing
Adds four methods to
Tests_Formatting_wpTexturizecovering the original report's quote-around-inline-HTML cases, the laterdata_inline_end_tagscases (including two the old engine marked unfixable), and the modern apostrophe case. Full focused class is green on current trunk:OK (361 tests, 469 assertions)PHPCS is clean against the WordPress-Core ruleset (
phpcs.xml.dist).A minimal apostrophe-only variant exists if maintainers prefer a narrower first step.
History
See WordPress/gutenberg#42345, which was closed correctly as a core
wptexturize()issue reported in Trac #18549. I've added a comprehensive revival comment there in Trac with a diff that's the same code in this PR.Developed with AI assistance (Anthropic Claude via Claude Code, and OpenAI Codex) under human review.