Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .noWS argument to withTags() #245

Merged
merged 6 commits into from
May 27, 2021
Merged

Add .noWS argument to withTags() #245

merged 6 commits into from
May 27, 2021

Conversation

gadenbuie
Copy link
Member

@gadenbuie gadenbuie commented May 6, 2021

Fixes #243

Offered as a possible solution to #243. Rather than adding a global option to control .noWS, this suggestion adds .noWS to withTags(), using the sketch from @wch in #243 (comment).

If .noWS isn't set, withTags() works as before.

withTags(
  div(
    class = "myclass",
    h3("header"),
    p("One", strong(span("two")), "three")
  )
)
#> <div class="myclass">
#>   <h3>header</h3>
#>   <p>
#>     One
#>     <strong>
#>       <span>two</span>
#>     </strong>
#>     three
#>   </p>
#> </div>

But setting .noWS on withTags() sets the whitespace option for all tags in the withTags() call.

withTags(
  div(
    class = "myclass",
    h3("header"),
    p("One", strong(span("two")), "three")
  ),
  .noWS = c("outside", "inside")
)
#> <div class="myclass"><h3>header</h3><p>One<strong><span>two</span></strong>three</p></div>

You can still set .noWS on individual tags to override the whitespace option for an individual tag.

withTags(
  div(
    class = "myclass",
    h3("header"),
    p("One", strong(span("two"), .noWS = "inside"), "three")
  ),
  .noWS = c("outside")
)
#> <div class="myclass"><h3>header</h3><p>
#>     One
#>     <strong><span>two</span></strong>
#>     three
#>   </p></div>

If this seems like a reasonable approach, I can follow up with additional tests.

R/tags.R Outdated Show resolved Hide resolved
Copy link
Collaborator

@schloerke schloerke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM given suggestion

@wch
Copy link
Collaborator

wch commented May 14, 2021

Can you add some unit tests?

NEWS.md Outdated Show resolved Hide resolved
@gadenbuie
Copy link
Member Author

gadenbuie commented May 27, 2021

I think the failing checks were just unlucky; they didn't make it past the setup step on macOS. I can't re-run the jobs but I suspect the checks would pass if someone were to do that for me. 😇

@schloerke
Copy link
Collaborator

Checks pass. @wch , Ok to merge?

@wch wch merged commit 7fbab16 into rstudio:master May 27, 2021
@gadenbuie gadenbuie deleted the option-noWS branch October 5, 2021 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Control .noWS via global option
3 participants