Add non-breaking space inside French quotes

Created on 2 May 2023, almost 2 years ago
Updated 8 May 2024, 9 months ago

Problem/Motivation

At least in French, « foo » should become « foo »

Proposed resolution

The easiest way would be to patch SmartyPants::spaceToNbsp().
I don't know if it's OK, since it is an old unmaintained library?

Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

🇫🇷France prudloff Lille

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @prudloff
  • Status changed to Needs review almost 2 years ago
  • 🇫🇷France prudloff Lille

    For some reason, preg_replace("/\s([»])/", ' $1', 'foo « bar »') seems to also replace the « character and I am not sure sure why. Because of this, preg_replace("/\s([\!\?\:;»])/", ' $1', $t) wouldn't do what I wanted.
    So I had to work around this by using a separate preg_replace() without [].

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    5 pass
  • First commit to issue fork.
  • Status changed to Needs work 9 months ago
  • 🇺🇸United States benjifisher Boston area

    I don't know if it's OK, since it is an old unmaintained library?

    Right, I prefer not to touch it unless it is doing something obviously wrong.

    If we are going to change it, then we should add some tests to make sure that we are not getting some undesired behavior. Can you provide some test cases: strings before and after applying the typogrify filter? Better yet, could you add them to the data provider in the automated test?

    I am not sure that spaceToNbsp() is the right place to make this change. It does not match the purpose of that function, as described in its doc block.

    Looking at the code (but not testing) it seems that the change to i18nQuotes() will insert the non-breaking space in some cases that currently do not get any sort of space. That seems like an unwanted side effect.

Production build 0.71.5 2024