I'm building a Shiny app with some dynamically generated HTML which includes a link in mid-sentence. Unfortunately if I use the tags
functions to do this, every element has a space around it whether I want it or not.
For example, if I wanted to write
This is my favorite link ever!
One might think you could do this
p('This is my ', a(href = 'https://stackoverflow.com/', 'favorite link ever'), '!')
But this results in each element being on a separate line, which by the HTML spec means there will be a space rendered between each.
<p>
This is my
<a href="https://stackoverflow.com/">favorite link ever</a>
!
</p>
Which looks like this (note the space before the exclamation mark)
This is my favorite link ever !
Do I have to resort to using HTML(paste0(...))
to construct my HTML, or is there some technique to using the tags
functions that I'm missing?
Thanks..
This has been resolved by a new feature, a parameter called .noWS
. Quoting Carson Sievert:
you can now do:
p('This is my ', a(href = 'https://stackoverflow.com/', 'favorite link ever', .noWS = "outside"), '!', .noWS = c("after-begin", "before-end"))
which yields
<p>This is my <a href="https://stackoverflow.com/">favorite link ever</a>!</p>
More information on the .noWS
parameter can be found at the pull request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With