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

Open
#311 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
Half a day
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
r
Domain
web-dev

Research direction

Start in R/html_dependency.R around lines 502-509 and compare how htmlDependency() and renderDependencies() currently handle named attributes for scripts. Confirm how the stylesheet path is rendered, then make stylesheet attributes behave consistently with scripts, including data-external. Done means generated link tags preserve the supplied attributes.

Written by the indexing model from the issue text.

Description

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 ?

Dominant language
R
Stars
225
Forks
73
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rstudio/htmltools

All issues in rstudio/htmltools

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.