New Figure extension #809
GiovanniSalmeri
started this conversation in
See what's new
Replies: 1 comment 3 replies
-
@GiovanniSalmeri Just out of curiosity, why don't you leave the value for the As a general advice: Aria roles should be omitted where possible, instead use the appropriate HTML elements. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everybody. I have written a new little extension Figure. Its purpose is to add images with captions. Any
[image]
can be changed into a[figure]
, without modifying the arguments, and theAlt
text will be used as a caption. The formatting of the page will not change (except, obviously, for the height of the figure, which will be greater). Any deviation from this intended behaviour should be considered a bug. Thank you for any comment!Now the longish explanations:
As regards implementation: the code that I have published is my third attempt. The first was entirely Javascript-based with a manipulation of DOM, the second leveraged
onParseContentHtml
. Both of them used a classcaption
added to a[image]
shortcut, both of them worked well, but I prefer to avoid client-side Javascript as much as possible, and withonParseContentHtml
a regex-based parsing of HTML was used. So in the end I devised an approach which usesonParseContentShortcut
and modifies the output of[image]
. A little parasitic 😊, but it works. (Obviously it uses regex, but only on a tiny and controlled fragment of HTML).As regards accessibility: theoretically, alt text and caption are two different things, but in the end I followed what seemed to me the wisest piece of advice. In the end, I think that where a description is relevant, both usability and accessibility are often improved by moving the description from alternative text to caption. Since empty attributes are stripped by Yellow normalisation, I used in
img
an alternative text with a blank space (which is almost the same thing) and added anaria-hidden
attribute. Finally, that an aria role is used instead of the nativefigure
depends on the fact that only in this way it is possible to create inline figures.Beta Was this translation helpful? Give feedback.
All reactions