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 4 commits into
base: master
Choose a base branch
from
Draft
Changes from 3 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 @@ -81,6 +81,17 @@ def process_doc(self, app: Sphinx, doctree: nodes.document) -> None:
if node['uri'] != original_uri:
node['original_uri'] = original_uri

# adapt refuri in figures if exists
original_refuri = node.parent.attributes.get("refuri")
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
node["original_refuri"] = original_refuri

# 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