r-lib / hugodown

Make websites with hugo and RMarkdown
https://hugodown.r-lib.org
Other
166 stars 24 forks source link

Plot output in chunk contains LaTeX \linewidth in width attribute of img tag #40

Closed jemus42 closed 4 years ago

jemus42 commented 4 years ago

See https://github.com/jemus42/hugodown-testing/blob/master/public/hugodown-rmarkdown/index.html#L221

<p><img src="plots/a-plot-1.png" width="0.95\linewidth" style="display: block; margin: auto;" /></p>

This results in the plot not being shown on the page, see here: https://hugodown-testing.netlify.app/hugodown-rmarkdown/#plots

When using e.g. Chrome's developer tools to remove the width attribute or correct it to width="95%", the plot appears.

I assume this is a result of the fix for #35 (re: https://github.com/r-lib/hugodown/issues/35#issuecomment-640577637)?

hadley commented 4 years ago

Yeah, I bet that's it; I think I can probably temporarily re-reset in hook_plot()

hadley commented 4 years ago

Nope, because out.widith = "95%" is converted to 0.95\\linewidth in fix_options() which is called by call_block(), which is called from process_group()

hadley commented 4 years ago

Regular expressions to the rescue 🤕