Skip to content

Avoid orphaned punctuation using non-breaking whitespace#11929

Merged
aduth merged 2 commits intomainfrom
aduth-i18n-punctuation-whitespace
Feb 27, 2025
Merged

Avoid orphaned punctuation using non-breaking whitespace#11929
aduth merged 2 commits intomainfrom
aduth-i18n-punctuation-whitespace

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Feb 27, 2025

🛠 Summary of changes

Enforces consistency of using non-breaking spaces within paired punctuation to avoid orphaned punctuation when line breaks occur, and fixes existing issues. It also adds French quotation characters ("guillemets": « ») as expected punctuation pairs.

The intent is to avoid the sorts of issues observed in #11911, consistently requiring that non-breaking spaces be used whenever there is whitespace within paired punctuation (parentheses, quotes, etc.).

Example (fixed in #11911):

Screenshot 2025-02-27 at 1 53 58 PM

📜 Testing Plan

Verify there's no regressions in the affected text. For example, ensure that the expanded banner text shows the lock icon within parentheses with whitespace.

image

changelog: User-Facing Improvements, Content Legibility, Avoid orphaned punctuation using non-breaking whitespace
Comment on lines -52 to +62
<br> <%= t('shared.banner.secure_description_html', lock_icon: render('shared/banner-lock-icon')) %>
<br>
<%= t(
'shared.banner.secure_description_html',
lock_icon: image_tag(
asset_path('lock.svg'),
width: 9,
height: 12,
class: 'usa-banner__lock-image',
alt: t('shared.banner.lock_description'),
),
) %>
Copy link
Contributor Author

@aduth aduth Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change addresses an edge-case where we previously relied on HTML whitespace collapsing with the space around the embedded lock and the final newline of the lock icon partial file. Using non-breaking spaces, the collapse doesn't occur, and therefore without these changes there's a slight increase in the amount of space to the right of the icon. The fix here inlines the icon rendering to avoid the trailing newline from the partial.

Before After
image image

It might also have a slight performance benefit of avoiding another partial load, and avoids some indirection for a partial that's not otherwise reused outside the banner.

@aduth aduth merged commit 402d007 into main Feb 27, 2025
2 checks passed
@aduth aduth deleted the aduth-i18n-punctuation-whitespace branch February 27, 2025 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants