-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
html_scaled_image_link behavior is too restrictive for extension developers #7032
Labels
Milestone
Comments
danwos
changed the title
<what happen when you do on which document project>
html_scaled_image_link behavior is too restricitve for extension developers
Jan 17, 2020
danwos
changed the title
html_scaled_image_link behavior is too restricitve for extension developers
html_scaled_image_link behavior is too restrictive for extension developers
Jan 17, 2020
tk0miya
added
type:enhancement
enhance or introduce a new feature
builder:html
and removed
type:bug
labels
Jan 25, 2020
I think it would be better if users also can control the scaled-image-links, not only from extensions. So I propose you to use "classes" attribute instead. What do you think? My idea:
|
tk0miya
added a commit
to tk0miya/sphinx
that referenced
this issue
Jan 25, 2020
tk0miya
added a commit
to tk0miya/sphinx
that referenced
this issue
Jan 25, 2020
Awesome, great idea. |
tk0miya
added a commit
that referenced
this issue
Feb 22, 2020
Close #7032: html_scaled_image_link is disabled for individual image
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm developing sphinx-extensions and my code is using
nodes.image
from docutils to add images to the documentation which shall be used as buttons, status or other indicators.But Sphinx is surrounding my images with
nodes.reference
, so that they become clickable links, which open the image in the browser.This is not the desired behavior, as I bind the images to javascrip (html only) to use them as buttons for specific actions.
Problem
sphinx/sphinx/builders/html.py
Line 808 in cad1f86
The handling of
html_scaled_image_link
does only look on the global config, but not on the image node itself, if maybe some attributes are set to avoid adding of references.So I can only switch off the behavior globally, which for sure is not an option.
Solution / Proposal
I propose the usage of a
target
attribute of the image node.If this is set, the target-value is used as refuri.
If it is set to None but part of node.attributes-dict, no reference should be added.
If it is not set (which is currently always the case), normal handling as of now.
As far as I have understood the docutils code, the handlers of images-nodes do not care about a
target
attribute.Workaround
Luckily I found on, but it is very ugly.
First off all, you need to add the image-node to a reference-node.
In this case, the
html_scaled_image_link
handling is aborted, as it stops if parent of an image-node is already a reference-node.But now you have a not wanted reference in your html-code, which forces the browser to jump/scroll the page when clicked on it.
So I must use some javascript to avoid this :(
Here the code for the important parts:
A loaded js-file needs to have this in it:
So, what do you think?.
I feel not really happy with the proposed solution.
Maybe someone else has a better idea, how to "deactivate" this behavior for sphinx extension developers.
The text was updated successfully, but these errors were encountered: