Closed dmurdoch closed 1 year ago
This seems related to #2169, but I don't think fig.id
has any effect when displaying an htmlwidget.
I have a better suggested change: the add_html_caption
function should insert the alt text if it detects that the widget needs it. I will submit a PR for this soon.
Thanks! I've tested this, and it's now working fine in the devel version of rgl.
Great! Thanks for testing! I just submitted the dev version to CRAN. Hopefully it will be on CRAN in a couple of days.
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.
In
rgl
I'd like to include alt text in the displays. For regular plots, the alt text is found using theoptions$fig.cur
value to index intooptions$fig.alt
.This code determines the
fig.cur
value and uses it to index intofig.alt
:https://github.com/yihui/knitr/blob/c50d30728857db278954e5a59a35a188b52934ce/R/output.R#L495-L499
where
reduce_plot_opts
does the indexing, changingfig.alt
and some other options to scalars.The code is run very late in the rendering process, because not all lines of code that generate plots result in having them shown in the final document: low level changes (like adding annotations to a base plot) suppress the display of the previous plot. By the time this is run for
rgl
widgets, the data in the widget is fixed, so there's no opportunity forrgl
code to see the appropriate alt text.Would it be possible to include the
fig.cur
value in some attribute of thediv
that wraps the widget? Then I could save the wholefig.alt
vector in thergl
data, and index into it at rendering time.Another approach to solve this would be to dispatch to the next method after
knit_asis
instead of hard-coding theknit_asis_htmlwidget
handling.