- Issue created by @jacobupal
- @jacobupal opened merge request.
- 🇬🇧United Kingdom jacobupal Leeds
(The failing tests on the issue branch don't seem to be related to the file I changed)
The house style for our organization is to not include a trailing period in abbreviations (e.g. "Doing D.I.Y is fun."). However this seems not to be properly captured by the "Wrap Caps" filter, and the last initial is not wrapped.
The same problem was apparently reported and fixed in version 7 here: Wrap Caps is inconsistent (2304643) → - the code intended to fix the issue seems to have been carried forward to version 8, but doesn't behave as it should, at least not in version 8.
Looking at the the regex on line 90 of src/Typogrify.php and testing it locally - I can see the solution is most of the way there but still looks for a period followed by possible white-space (\.\s?
) - This period would not exist for the last initial of period-separated abbreviations without trailing periods hence it is not captured.
Here's the line in question:
(?:[[\p{Lu}]+\.\s?)+) # Followed by the same thing at least once more
We can make period optional on proceeding initials by appending the ?
quantifier after \.
1. Enter the following text into a new article using a text-format
"D.I.Y is a great way to save money on home renovation.
2. Save the article
3. Inspect element in your browser to view the rendered markup as follows
<span class="caps">D.I.</span>Y is a great way to save money on home renovation.
4. Note that the "Y" is not captured in the span.
Change line 90 of src/Typogrify.php from...
(?:[[\p{Lu}]+\.\s?)+) # Followed by the same thing at least once more
..to...
(?:[[\p{Lu}]+\.?\s?)+) # Followed by the same thing at least once more
Create MR
Review by maintainers
Revisions/Changes
Merge
Rendered text before (with wrapped caps styled red)
Rendered text after (with wrapped caps still styled red)
N/A
N/A
Active
1.0
Code
(The failing tests on the issue branch don't seem to be related to the file I changed)