Skip to content

Conversation

@CybotTM
Copy link
Contributor

@CybotTM CybotTM commented Jan 2, 2026

Summary

Implements the :nbsp: text role which produces a non-breaking space ( ). This provides an explicit alternative to the ~ syntax (e.g., a~b) for inserting non-breaking spaces.

Usage:

This is a non breakable space: a :nbsp:`ignored` b

The content inside the role is ignored; the role simply produces a non-breaking space.

Background

  • The functional test for :nbsp: was imported from doctrine/rst-parser in commit 77e1f40c
  • The infrastructure (WhitespaceInlineNode and nbsp.html.twig template) already existed
  • Only the text role class was missing, so the test was marked as SKIP

Changes

  • Add NbspTextRole class that returns WhitespaceInlineNode
  • Register the text role in the service configuration
  • Remove SKIP marker from the functional test

Test plan

  • Run functional test nbsp-role - now passes
  • PHPCS - no errors
  • PHPStan - no errors
  • Unit tests - all pass
  • Functional tests - 9 incomplete (was 10)

Implements the :nbsp: text role which produces a non-breaking space
( ). This provides an explicit alternative to the ~ syntax
(e.g., a~b) for inserting non-breaking spaces.

Usage: :nbsp:`ignored content`

The content is ignored; the role simply produces a non-breaking space.
This completes existing infrastructure (WhitespaceInlineNode and
nbsp.html.twig template) that was added but never wired up.
Remove SKIP marker now that the :nbsp: text role is implemented.
@CybotTM
Copy link
Contributor Author

CybotTM commented Jan 2, 2026

Alternative: Remove the test instead?

After implementing this, I'm questioning whether the :nbsp: role is actually needed:

The ~ syntax already works:

a~b  →  a b

The :nbsp: role is more verbose and requires dummy content:

a :nbsp:`x` b  →  a   b

Options

  1. Merge this PR - Keep the role for feature parity with doctrine/rst-parser
  2. Remove the test instead - The ~ syntax is sufficient, less code to maintain
  3. Keep as SKIP - Leave it as a known limitation

Question for maintainers

The test was imported from doctrine/rst-parser (commit 77e1f40c), but the implementation was never added. Was this intentional (:nbsp: role not wanted) or an oversight?

If the :nbsp: role isn't needed, I'm happy to close this PR and submit one that removes the tests/Functional/tests/nbsp-role/ directory instead.

Copy link
Member

@jaapio jaapio left a comment

Choose a reason for hiding this comment

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

Thanks for this PR, this test slipped through our reviews.

@jaapio jaapio merged commit cce4441 into phpDocumentor:main Jan 4, 2026
58 checks passed
@jaapio
Copy link
Member

jaapio commented Jan 4, 2026

Thanks for this fix!

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