bookdown icon indicating copy to clipboard operation
bookdown copied to clipboard

Copy button should only copy code

Open hadley opened this issue 3 years ago • 6 comments

  • Need to update tooltip
  • Probably just regexp to strip out lines starting with #>

hadley avatar Feb 01 '21 17:02 hadley

Maybe adding a hook that gives a certain class to the output (as downlit::evaluate_and_highlight() would have done) -- then some xml2 tweaking as in https://github.com/r-lib/pkgdown/pull/1706/

maelle avatar Jun 03 '21 13:06 maelle

This should probably wait until after we change how pkgdown/bookdown generates the divs within a code chunk.

hadley avatar Jun 03 '21 18:06 hadley

But wouldn't changing these divs require adding a knitr hook? Or is this a downlit thing?

maelle avatar Jun 04 '21 07:06 maelle

Right — currently I always set collapse = TRUE which destroys all the divs within a chunk. I now see a way to get the styling I want while preserving those internal chunks.

hadley avatar Jun 04 '21 17:06 hadley

I now see a way to get the styling I want while preserving those internal chunks.

Do you mean a change should happen in downlit?

maelle avatar Jun 14 '21 11:06 maelle

This issue is to be tackled after https://github.com/r-lib/pkgdown/pull/1706 (since the logic should be the same).

maelle avatar Jun 14 '21 12:06 maelle