I have a R variable containing some html content inside, for exemple :
myvar = "<h3>Section Title</h3>"
I would like to print it not as <h3>Section Title</h3>
but as a formated h3 title in html or markdown that jupyter notebook understands.
I have been looking a bit everywhere and found htmlwidget
or knitr
but I feel like it needs a HTML file. What I would like to do is just displaying a variable.
I have tried also with htmltools
package and the HTML()
function, but no success...
myvar = "<h3>Section Title</h3>"
# I would expect that I can do something like:
print(HTML(myvar), format='html')
# But it doesn't work, I just get:
# => <h3>Section Title</h3>
And to be very clear, the goal is also that when I save the notebook as HTML or as PDF, the html is displayed formatted (and not as raw text)
In Fine the goal is to display the citations for loaded packages, in a aesthetic way. I know that I can use print(citation("packagename"), style='html')
to output it as HTML but I can't find how to format the HTML properly. That's the reason my idea is to capture this output in a variable and output it as formatted HTML.
Test
")` only displays `'Test
'`. Same result but without the quotes if used in terminal: `Test
`. (just a note that the `HTML()` function comes from `htmltools` package) – vinalti Apr 20 '22 at 09:33