Open alanocallaghan opened 3 years ago
Thanks for the report. I worked on this feature, so I'll have a look at your reproducible example. And then I'll have a look at your PR.
Can you clarify what results you are expecting ?
The fig.alt
feature was made primarly for HTML output, and is not correctly supported in other type of output.
When I render the document to rmarkdown::html_document()
using rmarkdown::render("test.Rmd", rmarkdown::html_document(keep_md=TRUE)"
, this is the content of the md file I get before convertion to HTML
---
title: Testing alt-text
output:
html_document:
keep_md: true
---
```r
knitr::include_graphics("mcgriff.png")
knitr::include_graphics("mcgriff.png")
knitr::include_graphics("mcgriff.png")
knitr::include_graphics("mcgriff.png")
It seems in this case, this is the expected result. isn't it ?
It would be interesting to have the detailed of what you expect. Either in the issue discussion here, or as detailed explanation in your PR.
Changing this feature is touchy and we need to make sure we improve one output without breaking another one. That is why I am interested in the detail of your use case (you are not using **rmarkdown** and only **knitr** ?
Thanks!
Yes, I am only using knitr
to knit to a markdown document. You can see here that knitr::knit
overwrites the fig.cap
as the title attribute of the img
tag when fig.alt
is set.
Specifically, the output is:
---
title: Testing alt-text
---
```r
knitr::include_graphics("mcgriff.png")
knitr::include_graphics("mcgriff.png")
knitr::include_graphics("mcgriff.png")
knitr::include_graphics("mcgriff.png")
while I would hope it would be
````md
---
title: Testing alt-text
---
```r
knitr::include_graphics("mcgriff.png")
knitr::include_graphics("mcgriff.png")
knitr::include_graphics("mcgriff.png")
knitr::include_graphics("mcgriff.png")
The reason I'm knitting to a markdown doc rather than html directly is because it's part of a jekyll site setup, fwiw. Part of a carpentries lesson.
The reason I'm knitting to a markdown doc rather than html directly is because it's part of a jekyll site setup, fwiw. Part of a carpentries lesson.
That is really interesting. We don't have a jekyll_document
indeed. So we need to make fig.alt
supported for markdown output resulting of knitr::knit
with Rmd
input.
That makes sense to me now. Thanks for the precision!
I was very grateful to find the new alt-text feature. However it doesn't seem to work as described, and when both
fig.cap
andfig.alt
are supplied, onlyfig.alt
is present in the output. This is not ideal as alt-text may need be more detailed than the caption for some images.I have made a tiny testing repo here to demonstrate: https://github.com/Alanocallaghan/testalt/ The issues page suggests zipfiles, so here's that repo as a zip too: testalt.zip
By filing an issue to this repo, I promise that
xfun::session_info('knitr')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('yihui/knitr')
.I understand that my issue may be closed if I don't fulfill my promises.