Skip to content

Add SemanticSpanExtension for kbd, dfn, abbr elements#77

Merged
dereuromark merged 3 commits intomasterfrom
feature/semantic-span-extension
Feb 5, 2026
Merged

Add SemanticSpanExtension for kbd, dfn, abbr elements#77
dereuromark merged 3 commits intomasterfrom
feature/semantic-span-extension

Conversation

@dereuromark
Copy link
Contributor

Summary

  • Adds SemanticSpanExtension that converts span attributes into semantic HTML5 elements
  • Supports kbd (keyboard input), dfn (definitions), and abbr (abbreviations)
  • Adds getChildrenHtml() to RenderEvent for extensions that need to wrap children in different HTML elements

Syntax Examples

Press [Ctrl+C]{kbd} to copy.
A [variable]{dfn} is a named storage location.
The [HTML]{abbr="HyperText Markup Language"} standard.
[CSS]{dfn abbr="Cascading Style Sheets"}

Output:

<kbd>Ctrl+C</kbd>
<dfn>variable</dfn>
<abbr title="HyperText Markup Language">HTML</abbr>
<dfn><abbr title="Cascading Style Sheets">CSS</abbr></dfn>

Inspired by php-collective/wp-djot#5

Adds a new extension that converts spans with semantic attributes
into proper HTML5 semantic elements:

- `[Ctrl+C]{kbd}` → `<kbd>Ctrl+C</kbd>`
- `[term]{dfn}` → `<dfn>term</dfn>`
- `[HTML]{abbr="..."}` → `<abbr title="...">HTML</abbr>`

Attributes can be combined, with dfn wrapping kbd wrapping abbr.
Other attributes (classes, IDs) are preserved in an outer span.

Also adds `getChildrenHtml()` to RenderEvent for extensions that
need to wrap children in different HTML elements.
@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 95.65217% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.81%. Comparing base (a6e227a) to head (a2e211c).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/Event/RenderEvent.php 87.50% 1 Missing ⚠️
src/Extension/SemanticSpanExtension.php 97.29% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #77      +/-   ##
============================================
+ Coverage     93.76%   93.81%   +0.05%     
- Complexity     2077     2095      +18     
============================================
  Files            76       77       +1     
  Lines          5595     5641      +46     
============================================
+ Hits           5246     5292      +46     
  Misses          349      349              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dereuromark dereuromark merged commit 7519524 into master Feb 5, 2026
4 checks passed
@dereuromark dereuromark deleted the feature/semantic-span-extension branch February 5, 2026 21:06
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.

1 participant