Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#31886 closed defect (bug) (fixed)

Make Single Quotes Curly before a Semicolon

Reported by: biranit's profile Biranit Owned by: miqrogroove's profile miqrogroove
Milestone: 4.3 Priority: normal
Severity: normal Version: 1.5
Component: Formatting Keywords: wptexturize has-patch
Focuses: Cc:

Description

The function wptexturize alters single quotes followed by spaces or ending punctuation from regular ' to a curly closing quote.

However, the regex appears to be missing at least the semi-colon as a punctuation mark:

  // Single quotes followed by spaces or ending punctuation.
  if ( "'" !== $closing_single_quote ) {
	 $dynamic[ '/\'(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $closing_single_quote;
  }

(And looking at it, I believe it's also missing the colon mark).

The result is that in a sentence with opening and closing single quote, followed by a semi-colon, the closing quote is wrongly texturized. Please see attached image to illustrate.

Thank you,

Bira

Attachments (3)

Screen Shot 2015-04-04 at 13.40.01.png (50.2 KB) - added by Biranit 9 years ago.
wrong closing single quote when followed by semi-colon
Screen Shot 2015-04-04 at 13.51.20.png (29.9 KB) - added by Biranit 9 years ago.
and this works just fine if there's a period instead of a semi-colon
miqro-31886.patch (5.1 KB) - added by miqrogroove 9 years ago.

Download all attachments as: .zip

Change History (13)

@Biranit
9 years ago

wrong closing single quote when followed by semi-colon

@Biranit
9 years ago

and this works just fine if there's a period instead of a semi-colon

#1 @miqrogroove
9 years ago

  • Keywords needs-unit-tests wptexturize added
  • Version changed from 4.1.1 to 1.5

This should be doable. In the past, there had been requests to include semi-colons before punctuation, which creates some technical problems. After punctuation is more straightforward.

#2 @miqrogroove
9 years ago

  • Summary changed from wptexturize closing single quotes regex missing punctuation marks to Make Single Quotes Curly before a Semicolon

Blame note: Prior to my work on 4.0, only a period or a whitespace was allowed after single quotes. Single quote logic remains different from double quotes due to the special cases.

#3 @miqrogroove
9 years ago

Looks like we can add colons, exclamations, and question marks as well.

All the existing tests pass, so I just need to type up some extra new tests and then this should be ready for review.

#4 @Biranit
9 years ago

That would be wonderful, @miqrogroove. Thank you

#5 @miqrogroove
9 years ago

  • Keywords has-patch 4.3-early added; needs-unit-tests removed

#6 @obenland
9 years ago

  • Owner set to miqrogroove
  • Status changed from new to assigned

#7 @obenland
9 years ago

  • Keywords 4.3-early removed
  • Milestone changed from Awaiting Review to 4.3

#8 follow-up: @Biranit
9 years ago

  • Keywords changed from wptexturize, has-patch to wptexturize has-patch

Hi,

I'm wondering if there is a way to solve this as a plugin or via filter in the interim? It's been two months and my editors are suffering :)

Apologies for nagging.

Thanks,

Bira

#9 in reply to: ↑ 8 @miqrogroove
9 years ago

Replying to Biranit:

I'm wondering if there is a way to solve this as a plugin or via filter in the interim?

Sorry, but the easiest interim fix would be to hack your formatting.php file.

#10 @wonderboymusic
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 32789:

Improve the consistency of punctuation matching in wptexturize().

Adds unit tests.

Props miqrogroove.
Fixes #31886.

Note: See TracTickets for help on using tickets.