Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1213.
With
html_imageenabled,<img src="example.png" alt="A # sign">currently produces alt textAand a warning. Decoded quotes can drop the alt attribute entirely, and embedded newlines can truncate it. HTML attributes are being serialized into directive option text and parsed a second time.Pass the existing allowed attributes through
run_directive(..., additional_options=...)instead. Directive option validation remains active. Trim width/height values to preserve the former dimension whitespace normalization, while preserving literal alt text, including its leading/trailing spaces.Regression tests cover block and inline images, quotes, hash signs, embedded newlines, literal alt whitespace, padded numeric/unit/percentage dimensions, and invalid dimensions. The three-file change includes an Unreleased changelog entry.
Compatibility observation: the synthesized directive
block_textand resulting standard image node'srawsourcenow become empty instead of containing generated:key: valuelines. This was observed in a local probe. Custom image directives or downstream consumers that inspect those fields may observe a difference; compatibility with all such consumers has not been established.This addresses HTML attribute conversion in
html_to_nodes.py. #1210 / #1211 address a separate Markdown image token path inrenderInlineAsText.Validation on macOS with Python 3.11.16:
tox -e py311-sphinx8,py311-sphinx9 -- tests/test_html tests/test_docutils.py tests/test_renderers/test_parse_directives.py -q: 136 passed on each stack (Sphinx 8.2.3 / docutils 0.21.2 and Sphinx 9.0.4 / docutils 0.22.4).tox -e py311-sphinx9 -- -q: 1,265 passed, 11 skipped; 22 existing BeautifulSoupfindAlldeprecation warnings in the Sphinx test helpers.pre-commit run --all-files: all seven configured checks passed, including Ruff and mypy.git diff --check: passed.Tox was invoked using
uv tool run --from tox --with tox-uv tox. Sphinx 8 received the focused suites, not the full suite. Other Python/platform combinations, the separate docutils-only matrix, standalone documentation/LaTeX builds, and the 11 skipped tests were not exercised locally. Hosted CI results are separate from these local results.AI assistance was used to prepare the implementation and regression tests.