yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.36k stars 873 forks source link

fix: restructuredText figure caption and alt #2269

Closed trevorld closed 10 months ago

trevorld commented 11 months ago

fixes #2023

trevorld commented 10 months ago

I wonder if it's easier to add arguments to .img.cap() instead of forking it. Thanks!

One approach could be:

  1. Add a new argument to .img.cap() with the target output format like output = "md" or output = "rst"
  2. Update all calls to .img.cap() with this argument
  3. Only do the html escaping and/or label creating for the formats that need/support them
yihui commented 10 months ago

I'll take care of the rest of work. Thank you!

  • Presumably html output needs the html escaped image alt and latex output needs the label prefix?

Yes, that's about right. For rst output, the label won't be created.