Skip to content
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

feat: adapt image refuri if image uri has been adapten by i18n #12849

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions sphinx/environment/collectors/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@
if node['uri'] != original_uri:
node['original_uri'] = original_uri

# adapt refuri in figures if exists
original_refuri = node.parent.attributes.get("refuri")

Check failure on line 93 in sphinx/environment/collectors/asset.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (Q000)

sphinx/environment/collectors/asset.py:93:62: Q000 Double quotes found but single quotes preferred
if original_refuri:
new_file_name = os.path.basename(imguri)
new_refuri = os.path.join(
os.path.dirname(original_refuri), new_file_name
)
if new_refuri != original_refuri and os.path.isfile(new_refuri):
node.parent.attributes["refuri"] = new_refuri

Check failure on line 100 in sphinx/environment/collectors/asset.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (Q000)

sphinx/environment/collectors/asset.py:100:48: Q000 Double quotes found but single quotes preferred
node["original_refuri"] = original_refuri

Check failure on line 101 in sphinx/environment/collectors/asset.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (Q000)

sphinx/environment/collectors/asset.py:101:30: Q000 Double quotes found but single quotes preferred

# map image paths to unique image names (so that they can be put
# into a single directory)
for imgpath in candidates.values():
Expand Down
Loading