-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: plot directive not handling indentation of long option strings #29649
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
Comments
This is a rst field list, I suspect (but haven't checked) that the correct way to handle multilines is to also indent the first line, see https://docutils.sourceforge.io/docs/user/rst/quickref.html#field-lists (see |
Unfortunatly that didn't work either far as I can tell (pushed this attempt to PR) |
I only took a very quick look, but I don't think we are doing any of the parsing ourselves: matplotlib/lib/matplotlib/sphinxext/plot_directive.py Lines 254 to 274 in 177f28c
we are leaving that to sphinx/docutils. Maybe adding a line continuation ( |
Try an If that does not work either, it's a docutils issue - either a bug or an incorrect documentation. |
@timhoffm tested the following and this works as expected, with all the alt text in the alt attribute of the image .. image:: ../_static/anatomy.png
:alt:
8 squares, each showing the pattern corresponding to the hatch symbol:
symbol '/' makes right leaning diagonals, '\\' makes left leaning diagonals,
'|' makes vertical lines, '-' makes horizontal lines, '+' makes a grid,
'X' makes a grid rotated 90 degrees, 'o' makes small unfilled circles,
'O' makes large unfilled circles, '.' makes small filled circles, and '*' makes
a star with 5 points while this: .. plot:: _embedded_plots/hatch_classes.py
:alt:
8 squares, each showing the pattern corresponding to the hatch symbol:
symbol '/' makes right leaning diagonals, '\\' makes left leaning diagonals,
'|' makes vertical lines, '-' makes horizontal lines, '+' makes a grid,
'X' makes a grid rotated 90 degrees, 'o' makes small unfilled circles,
'O' makes large unfilled circles, '.' makes small filled circles, and '*' makes
a star with 5 points generates this output where there's alt text then directive information then alt text again, which to me points to a parsing error in |
It is strange, because
So there should be no difference in parsing. |
It must be a bug with |
For reasons I don't quite understand, the plot directive renders the plots, and then templates it out into new reST, which is inserted into the parser after it. This path through text again doesn't handle multi-line input and is what causes the breakage. |
Bug summary
In #29644, I couldn't wrap alt text because the alt field wasn't getting properly parsed by the plot directive. Instead it yeilded something like the following for every variant
Code for reproduction
Actual outcome
Expected outcome
The alt text properly parsed so just the image shows and the alt txt is put into the html
Additional information
Matplotlib Version
dev
The text was updated successfully, but these errors were encountered: