-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
French d'Words and l'Phrases capitalization #539
Conversation
Codecov Report
@@ Coverage Diff @@
## master #539 +/- ##
==========================================
- Coverage 75.73% 73% -2.73%
- Complexity 1447 1452 +5
==========================================
Files 9 9
Lines 2477 2497 +20
==========================================
- Hits 1876 1823 -53
- Misses 601 674 +73
Continue to review full report at Codecov.
|
expandFns.php
Outdated
@@ -221,6 +221,17 @@ function title_capitalization($in, $caps_after_punctuation) { | |||
create_function('$matches', 'return mb_strtolower($matches[0]);'), | |||
trim($new_case) | |||
); | |||
|
|||
$new_case = preg_replace_callback("/ (L')([a-zÀ-ÿ]+)/", function($matches) { /** French l'Words **/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need to match unicode alternatives to the apostrophe, i.e. ’ and kin?
expandFns.php
Outdated
}, ' ' . $new_case); | ||
$new_case = mb_ucfirst(trim($new_case)); | ||
|
||
$new_case = preg_replace_callback("/ (D')([a-zÀ-ÿ]+)/", function($matches) { /** French d'Words **/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use \b to match a word boundary, i.e. `\b(D'). And there's no need for brackets around the (D') / (L') as if there is a match, we don't need to refer to $matches to figure out what it will be!
Just to be thorough (-:
Add some more short words. - d'un and d'une should be removed in #539.
@ms609 Thoughts? I made your tests even harder. |
@ms609 It actually works now |
@@ -221,6 +221,20 @@ function title_capitalization($in, $caps_after_punctuation) { | |||
create_function('$matches', 'return mb_strtolower($matches[0]);'), | |||
trim($new_case) | |||
); | |||
/** French l'Words and d'Words **/ | |||
$new_case = preg_replace_callback( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about a single function matching (\s[LD])
and replacing with mb_strtolower($matches[1])? This'll avoid duplication and keep the code leaner.
Does preg_replace_callback match all occurrences of the search expression?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes all
No description provided.