问题描述
我有一个 Bookdown 网站,我想将它嵌入到 R Shiny 应用程序中,但是我遇到了一个问题,即只有顶部工具栏才能正确呈现。我正在使用基本的 Bookdown 模板并使用 gitbook
选项呈现网站,然后尝试将 html 文件嵌入到 R Shiny 应用程序中,如下面的代码所示。
全屏显示时,只有顶部工具栏可见:
当窗口变小时,很明显内容的主体正在被渲染,但是在靠近顶部的一个非常小的盒子里:
不清楚为什么会发生这种情况,我已经在较大的 R Shiny 应用程序以及下面的极简示例中尝试过。我最初使用较大的 Bookdown 站点尝试了此操作,然后使用了较小的示例,包括 reprex 中的单页站点。是什么导致了这种奇怪的渲染,是否有可能在 Shiny 应用环境中解决这个问题?
server.R 文件
library(shiny)
library(htmltools)
shinyServer(function(input,output,session) {
output$ui <- renderUI({
htmltools::includeHTML("./www/index.html")
})
})
ui.R 文件
library(shiny)
shinyUI(
uIoUtput("ui")
)
_bookdown.yml
book_filename: "Bookdown Reprex"
output_dir: www
delete_merged_file: true
language:
label:
fig: "figURE "
tab: "TABLE "
ui:
chapter_name: ""
_output.yml
bookdown::pdf_book:
keep_tex: yes
latex_engine: xelatex
pandoc_args: --top-level-division=chapter
toc_depth: 2
toc_unnumbered: no
bookdown::gitbook:
css: css/style.css
split_by: chapter
lib_dir: book_assets
config:
toc:
collapse: chapter
download: pdf
sharing: no
index.Rmd
---
title: "Bookdown Reprex"
date: "`r Sys.Date()`"
fontsize: 11pt
geometry: margin=1in
mainfont: FreeSans
site: bookdown::bookdown_site
always_allow_html: yes
colorlinks: yes
---
Introduction
============
```{r setup,include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting Syntax for authoring HTML,PDF,and MS Word documents. For more details on using R Markdown see
<http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content
as well as the output of any embedded R code chunks within the document. You can embed an
R code chunk like this:
```{r cars}
summary(cars)
```
style.css
p.caption{
color: #777;
margin-top: 10px;
}
p code {
white-space: inherit;
}
pre {
word-break: normal;
word-wrap: normal;
}
pre code {
white-space: inherit;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)