Fix some issues with plots.pl and the graph tool. #1322
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.
First, fix the alt attribute for TikZ and GD image types for plots.pl.
The
image
method ofPGbasicmacros.pl
currently sets thearia_description
with the value of thealt
option if it is passed to the method, and it does so regardless of the plots image type. However, that is only used forhtml
output with JSXGraph. Thus for TikZ or GD image types the alt attribute is lost. This makes it so that thearia_description
is only set forhtml
output, and for all other outputs the given alt tag is left in the@alt_list
so that the later code that inserts the<image>
tag can get it and add it as an attribute to the<image>
tag.You can test this with the following MWE:
With that example and the current code, the image will not have an alt attribute, but will with this pull request. If you remove the line that sets the image type to 'tikz', then the JSXGraph image will get the aria description (with the second fix below).
Second, fix the aria description for both JSXGraph output of plots.pl and the graph tool.
This is caused by the removal of the
description
option for theJXG.Board
object in the JSXGraph library. I must have missed this when this happened three years ago. Although, it seems to have been done rather quietly, as this is not listed in the change log for JSXGraph.To fix this, I just do the same thing that the
description
option used to do, and add a visually hidden span that the graph isaria-describedby
. Note that there is a newaria-description
attribute that could be used in the future for this, but it is in a future aria specification, and I don't know how well supported it is at this point.Finally, fix some issues with GD output of the plots.pl macro. This is caused when an Plots::Plot object does not have the height explicitly set. For TikZ and JSXGraph output, the
size
method is called which determines the height if it is not set explicitly. So GD output should do the same.