1

Is it possible to dynamically render markdown and create tooltips on the output?

I imagine some .md document like

# myfile.md
This is a <span class="tippy", data-tippy-content="markdown is a simple text 
format">markdown</span> document.

(the idea of "data-tippy-content" comes from the examples section of the "tippy" package.)

The shiny app would then look like

library(shiny)
library(tippy)

shinyApp(
  ui = fluidPage(
        shiny::markdown(readLines("myfile.md")),
        tippy_this(".tippy")
 ),
 server = function(input, output, session) {}
)

However, when I run this, I get an error "must pass tooltip.".

Any hint appreciated!

Karsten W.
  • 17,826
  • 11
  • 69
  • 103
  • I just learned that there is this [new HTML tag `attr`](https://stackoverflow.com/a/38309183/216064) that seems more straightforward. – Karsten W. Sep 01 '23 at 14:16

1 Answers1

1

Looks like you are using the CRAN version (0.1.0 from 2018) whereas the docs and the examples refer to the dev version (1.0.0), i.e. your code works fine using the dev version.

Note: I also fixed a typo in your md, HTML attributes should not be separated by a ,.

library(shiny)
library(tippy)

shinyApp(
  ui = fluidPage(
    shiny::markdown(readLines("myfile.md")),
    tippy_this(".tippy")
  ),
  server = function(input, output, session) {}
)

enter image description here

myfile.md

This is a <span class="tippy" data-tippy-content="markdown is a simple text 
format">markdown</span> document.
stefan
  • 90,330
  • 6
  • 25
  • 51