R DT 的页脚中的下标 withTags()

问题描述 投票:0回答:0

我正在尝试在 Shiny 应用程序中向 DataTables 页脚添加上标(类似于此处的行名/正文)。

library(shiny)
library(DT)

ui <- fluidPage(dataTableOutput("table"))

server <- function(input, output) {
  output$table <- renderDataTable({

    sketch <- htmltools::withTags(table(
      tableFooter(c(("Footer<sup>1</sup>"),
                     "Footer<sup>2</sup>"))
    ))

    data <- datatable(data.frame(c(1, 2),
                                 row.names = c("A<sub>1</sub>",
                                               "A<sub>2</sub>")),
                      rownames = TRUE,
                      container = sketch,
                      escape = FALSE)
  })
}

shinyApp(ui = ui, server = server)

然而,标签不是呈现为上标,而是按字面打印:

查看

sketch
表明大于/小于符号被转换为它们的 HTML 字符实体:

> sketch
<table>
  <tfoot>
    <tr>
      <th>Footer&lt;sup&gt;1&lt;/sup&gt;</th>
      <th>Footer&lt;sup&gt;2&lt;/sup&gt;</th>
    </tr>
  </tfoot>
</table>

我试图用

\
\\
htmltool's manual on
withTags()
逃脱它们但没有成功。 那么,如何转义更大/更小的符号以将它们保留为标签呢? 已经谢谢你了! :)

r dt htmltools
© www.soinside.com 2019 - 2024. All rights reserved.