rstudio / htmltools

Tools for HTML generation and output
https://rstudio.github.io/htmltools/
215 stars 68 forks source link

Allow to specificy `stylesheet` as `script` with named attibutes in `htmlDependency()` #311

Open cderv opened 2 years ago

cderv commented 2 years ago

Currently htmlDependency() allows to pass integrity SRI or any other attributes to script.

I wonder in continuation of https://github.com/rstudio/htmltools/issues/101 if we could add same logic for stylesheet.

This would allow renderDependencies() to generate a HTML with more than

<link href="path" rel="stylesheet" />

https://github.com/rstudio/htmltools/blob/e47232123e8916bf7c8d95f4513d0fa77c8f4d13/R/html_dependency.R#L502-L509

For example, I believe this would also allow to include HTML dependencies in R Markdown document output while adding data-external = 1 to indicated Pandoc should skip the link in self-contained operation. Currently, I don't think we can do it. This is the use case I have - I was just surprised it was not working the same as I can't add more attributes to the <link> tag and wondered why. 🤔

What about adding the same logic for stylesheets and scripts ?

yihui commented 2 years ago

This is important to us. @cpsievert Would you like a pull request?

wch commented 2 years ago

I think it makes sense to support arbitrary attributes on stylesheets.

cpsievert commented 2 years ago

A PR would be great. In case it's helpful, this is the initial PR for <script> #188 (see also #201).

We'll probably also need something similar to https://github.com/rstudio/shiny/pull/3395 in order to dynamically render the stylesheet attributes correctly

yihui commented 2 years ago

Yes, supporting arbitrary attributes will be even better!

@cderv Would you want to work on it? This is not urgent though since you have already had a workaround.

cderv commented 2 years ago

Yes I'll add that in the list. thanks !