pre
タグはすべての空白(プリフォーマット済み)を保持しているため、Shinyは自動的にHTMLコードをインデントして人間が読めるようにフォーマットしています。
もし興味があれば、shiny/htmltoolsを少し調べて、犯人を見つけることができます。私はこれを確認したかったので、私はこれが起こる場所を見つけました。
> mytag <- div(div())
> mytag
<div>
<div></div>
</div>
これは、字下げで印刷されているようです。それでは、
> class(mytag)
[1] "shiny.tag"
> getS3method("print", "shiny.tag")
function (x, browse = is.browsable(x), ...)
{
if (browse)
html_print(x)
else print(as.character(x), ...)
invisible(x)
}
<environment: namespace:htmltools>
がas.characterにリダイレクトと呼ばれるものを印刷する方法を見てみましょう、それでは、それは
> getS3method("as.character", "shiny.tag")
function (x, ...)
{
renderTags(x)$html
}
<environment: namespace:htmltools>
がrenderTagsにリダイレクト何をするか見てみましょう、のは、そこにそれを
> htmltools:::renderTags
function (x, singletons = character(0), indent = 0)
{
x <- tagify(x)
singletonInfo <- takeSingletons(x, singletons)
headInfo <- takeHeads(singletonInfo$ui)
deps <- resolveDependencies(findDependencies(singletonInfo$ui))
headIndent <- if (is.numeric(indent))
indent + 1
else indent
headHtml <- doRenderTags(headInfo$head, indent = headIndent)
bodyHtml <- doRenderTags(headInfo$ui, indent = indent)
return(list(head = headHtml, singletons = singletonInfo$singletons,
dependencies = deps, html = bodyHtml))
}
<environment: namespace:htmltools>
を見てみましょうです。インデントはのは
> htmltools:::renderTags(mytag, indent = 5)
$head
$singletons
character(0)
$dependencies
list()
$html
<div>
<div></div>
</div>
謎は、私は `paste0(ライン、崩壊="使用できる文字のベクトルのために!それは働く
偉大な説明@daattali今それは意味をなさない。 – Geovany