Open jiho opened 9 years ago
This is by design. Can you talk a little bit more about your use case? Why would you ever want a raw ampersand instead of &
? (Note that attributes in HTML are supposed to be HTML-escaped--the browser will un-escape when interpreting the attribute. See here for a fiddle that demonstrates this.)
Some Markdown processors "will also perform a bit of randomized decimal and hex entity-encoding to help obscure your address from address-harvesting spambots" (as per the Markdown syntax page). So
<address@example.com>
becomes
<a href="mailto:addre
ss@example.co
m">address@exa
mple.com</a>
As you can see there are unescaped &
in the href
part. I wanted to use this together with a()
. It used to work (when a()
was part of shiny), hence my "bug" report.
Joe,
I ran into this today and side with @jiho on this.
I agree with you. Normally, you would want HTML-escaping, but there are some instances/use cases that expect raw, unescaped HTML in attributes. I assumed as the OP that using HTML(...)
would prevent the HTML escaping for the attributes and can confirm that it does not.
I think think in this case, the OP has a point, HTML does not work as the documents lead you to believe. I would recommend either updating the docs to be more clear or (probably better) supporting the functionality that @jiho expected.
C-
Here is another use case.
I am hoping to use htmltools to help build MathML blocks to include in rmarkdown.
So, I need:
tag("mo", "∑")
to return:
<mo>∑</mo>
but, instead, I get:
<mo>&sum;</mo>
which, or course, will not produce epsilon I am looking for.
Am I missing something? Can htmltools help me?
THANKS
I used htmltools::tags$script(some_js_script)
and got into the same problem...
@agricolamz If you wrap the script portion in HTML()
it will be protected from escaping:
tags$script(HTML("alert('& hello world!)"))
#> <script>alert('& hello world!)</script>
And @mikebesso (sorry for the delay!) and anyone else with a similar issue, the minor missing detail is that tag()
expects a list of children or attributes, so list(HTML("∑"))
will work:
tag("mo", list(HTML("∑")))
#> <mo>∑</mo>
gives
when I would expect
NB: this is a problem to obfuscate email addresses using markdown for example.