You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had the same question, the problem seems to be that the < and > signs get converted to their HTML entities < and >, respectively, when passed into gt.
My solution was to create my own html function that replaced the entities with their signs before calling the HTML function.
Now, to make it work with multiple rows and columns, you'll have to add map to your function in text_transform since html returns one vector. There's probably a better way to do this but it would look something like this
data.frame(A= c("<b>Text</b>", "<del>Text</del>"), B= c("<em>Text</em>", "Text"), stringsAsFactors=FALSE) %>%
gt() %>%
text_transform(
locations= cells_data(vars(A, B)), # More than one column, rowfn=function(x){
purrr::map(x, html, replace_sign_entities=TRUE) # use map here
}
)
We do escaping to ensure that text is not retained as HTML. I think there is work to be done to make it easier to preserve inputs as HTML but we have to make sure that we do this without compromising security.
@leungi Aww thanks! There's still TONS of work to be done. So, thanks for being patient with the development process (and the little problems along the way).
@leungi Aww thanks! There's still TONS of work to be done. So, thanks for being patient with the development process (and the little problems along the way).
Without y'alls' hard work, it would've been a 🗻for me (with minimal HTML/CSS knowledge 😅) to do something like:
Activity
jdbarillas commentedon Jan 29, 2019
I had the same question, the problem seems to be that the
<and>signs get converted to their HTML entities<and>, respectively, when passed into gt.My solution was to create my own
htmlfunction that replaced the entities with their signs before calling the HTML function.and then use
text_transformas seen in #126 to pass it as the function. So with your example (addingstringsAsFactors = FALSE) it would look likeA
B
Text
Text
Now, to make it work with multiple rows and columns, you'll have to add
mapto your function intext_transformsincehtmlreturns one vector. There's probably a better way to do this but it would look something like thisA
B
Text
Text
TextText
Created on 2019-01-29 by the reprex package (v0.2.1)
rich-iannone commentedon Feb 1, 2019
We do escaping to ensure that text is not retained as HTML. I think there is work to be done to make it easier to preserve inputs as HTML but we have to make sure that we do this without compromising security.
rich-iannone commentedon Aug 3, 2019
This now works with
fmt_markdown(). Here's a working example:leungi commentedon May 12, 2020
@rich-iannone : can't express enough of my appreciation of your work with
gtandblastula; match made in heaven 😁🙏rich-iannone commentedon May 12, 2020
@leungi Aww thanks! There's still TONS of work to be done. So, thanks for being patient with the development process (and the little problems along the way).
leungi commentedon May 12, 2020
Without y'alls' hard work, it would've been a 🗻for me (with minimal HTML/CSS knowledge 😅) to do something like:
Kudos 🙌