Skip to content

Replace <em> with <span> for desc_annotation semantic HTML #13689

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

q2mark
Copy link

@q2mark q2mark commented Jun 22, 2025

Purpose

This PR replaces <em class="property"> with <span class="property"> in the HTML5 writer's visit_desc_annotation and depart_desc_annotation methods to improve semantic HTML structure for Python attribute type annotations.

Changes:

  • Modified sphinx/writers/html5.py to use <span> instead of <em> tags while maintaining the existing property CSS class
  • Updated corresponding test expectations in tests/test_domains/test_domain_py_pyobject.py

Benefits:

  • Improves semantic HTML structure
  • Prevents unintended visual styling of punctuation and type information
  • Enhances accessibility for screen readers

The change maintains all existing functionality and CSS styling while providing better semantic meaning.

References

Replace <em class="property"> with <span class="property"> in HTML5 writer's
visit_desc_annotation and depart_desc_annotation methods to improve semantic
HTML structure for Python attribute type annotations.

Fixes sphinx-doc#13688

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@q2mark q2mark force-pushed the fix-desc-annotation-semantic branch from 0288b94 to bba4f3d Compare June 22, 2025 21:41
@AA-Turner
Copy link
Member

Hi @q2mark this commit has the author of "Claude". Please confirm that this PR is entirely comprised of your own work, and you posses the legal right to copyright.

A

@AA-Turner AA-Turner added the awaiting:response Waiting for a response from the author of this issue label Jun 23, 2025
@q2mark
Copy link
Author

q2mark commented Jun 23, 2025

Hi @q2mark this commit has the author of "Claude". Please confirm that this PR is entirely comprised of your own work, and you posses the legal right to copyright.

A

@AA-Turner yes this is entirely my own work and I have the right to copyright.

Comment on lines +82 to +84
* #13688: HTML5: Replace ``<em class="property">`` with ``<span class="property">``
for Python attribute type annotations to improve semantic HTML structure.
Patch by Mark O.
Copy link
Member

Choose a reason for hiding this comment

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

Do you have a suggested link / reference for "semantic HTML structure"?

Suggested change
* #13688: HTML5: Replace ``<em class="property">`` with ``<span class="property">``
for Python attribute type annotations to improve semantic HTML structure.
Patch by Mark O.
* #13688: HTML builder: Replace ``<em class="property">`` with ``<span class="property">``
for Python attribute type annotations to improve semantic HTML structure.
Patch by Mark Ostroth.

@AA-Turner
Copy link
Member

Oh, please also add yourself to AUTHORS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting:response Waiting for a response from the author of this issue builder:html
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python attribute type annotations use inappropriate <em> tags, breaking semantic HTML
2 participants