rstudio / rmarkdown

Dynamic Documents for R
https://rmarkdown.rstudio.com
GNU General Public License v3.0
2.87k stars 977 forks source link

Isolated CSS for rmarkdown #1435

Open schloerke opened 6 years ago

schloerke commented 6 years ago

If I have a set of self-contained = false rmarkdown files that are rendered with an updated version of rmarkdown, every output file has updated css information.

While I like having the latest css, is it possible to put the rmarkdown css in a separate file (as my rmarkdown files are currently not self-contained). If they are self-contained, the substitution mechanism will put the css in it's proper place.

This would help avoid numerous false positive git changes and redirect those changes to a single css file. (Like an css htmldependency file?)

yihui commented 6 years ago

I have had this pain myself for a long time, too. Early last month I wrote an R script to post-process HTML files and extract CSS/JS code on the DT website: https://github.com/rstudio/DT/commit/af9d47e529c2ddb4cde751da2e283e79f1ccc0b9, which led to much cleaner HTML source code: https://github.com/rstudio/DT/commit/10357dd7f6dbdd86e7ffdef5fbdce83f505a37e6.

Yes, I believe HTML dependencies would be the way to go, as I mentioned in one of my recent PR reviews: https://github.com/rstudio/rmarkdown/pull/1405#pullrequestreview-137663612 Before someone could really work on it, you can probably just steal my code: https://github.com/rstudio/DT/blob/gh-pages/fragmentize.R