简体   繁体   English

bookdown 中从 git_book 更改为 bs4_book 时未正确呈现特殊字符

[英]Special characters not rendered correctly when changing from git_book to bs4_book in bookdown

I am working on a book using bookdown in Rstudio that was being rendered in git_book format, but after changing to bs4_book format all the Latin characters and even the apostrophe in English are not rendered correctly anymore (see image below).我正在使用bookdown中的 bookdown 编写一本书,该书以git_book格式呈现,但在更改为bs4_book格式后,所有拉丁字符甚至英文撇号都不再正确呈现(见下图)。 You can see the current live version inthis page and the repositoryhere .您可以在此页面此处的存储库中查看当前的实时版本。 图片

I installed this version of bookdown, remotes::install_github("rstudio/bookdown#1027") based on this issue in Github, and also installed bslib like this, remotes::install_github("rstudio/bslib")我根据Github中的这个问题安装了这个版本的bookdown, remotes::install_github("rstudio/bookdown#1027") ,还像这样安装了bslibremotes::install_github("rstudio/bslib")

When I render the book in bs4_book I got the following messages that I did not get before with git_book,当我在bs4_book中渲染这本书时,我收到了以下使用 git_book 没有收到的消息,

#> Tweaking docs/index.html
#> Tweaking docs/intro.html
#> Tweaking docs/folder-strcutures.html
#> Tweaking docs/collaboration-in-git.html
#> Tweaking docs/stata-github.html
#> Tweaking docs/intro-povcal.html
#> Tweaking docs/prepare.html
#> Tweaking docs/lis-data.html
#> Tweaking docs/primus.html

#> Warning messages:
#> 1: In parse(text = text, keep.source = TRUE, encoding = "UTF-8") :
#>   integer literal 02.L contains unnecessary decimal point
#> 2: In parse(text = text, keep.source = TRUE, encoding = "UTF-8") :
#>   integer literal 00.L contains unnecessary decimal point
#> 3: In parse(text = text, keep.source = TRUE, encoding = "UTF-8") :
#>   integer literal 02.L contains unnecessary decimal point
#> 4: In parse(text = text, keep.source = TRUE, encoding = "UTF-8") :
#>   integer literal 02.L contains unnecessary decimal point
#> 5: In parse(text = text, keep.source = TRUE, encoding = "UTF-8") :
#>   integer literal 00.L contains unnecessary decimal point
#> 6: In parse(text = text, keep.source = TRUE, encoding = "UTF-8") :
#>   integer literal 03.L contains unnecessary decimal point

You can see my session info below,你可以在下面看到我的 session 信息,

Thank you so much for your help.非常感谢你的帮助。 Best,最好的,

sessioninfo::platform_info()
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       America/New_York            
#>  date     2020-12-20
Sys.getlocale()
#> [1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252"
stringi::stri_locale_info()
#> $Language
#> [1] "en"
#> 
#> $Country
#> [1] "US"
#> 
#> $Variant
#> [1] ""
#> 
#> $Name
#> [1] "en_US"

Thanks for this question, I had a similar one!感谢这个问题,我也有类似的问题!

I'm afraid for me, the problem was not simply solved by deleting the docs folder where I had my html files.恐怕对我来说,问题并没有简单地通过删除我的html文件所在的docs文件夹来解决。

This discussion on GitHub resolved it for me though.不过,关于 GitHub 的讨论为我解决了这个问题。

The solution was to install the bookdown version from Pull Request #1027 where Hadley fixed this.解决方案是从 Pull Request #1027 安装bookdown版本,Hadley 修复了这个问题。

remotes::install_github("rstudio/bookdown#1027")

I presume this will be merged to the main branch soon, but for now, this did it for me.我想这将很快合并到主分支,但现在,这对我来说是这样做的。

I found the solution to the problem.我找到了问题的解决方案。 While trying to create a replicable example as suggested by @JosefZ, I literally copied and pasted from the original repo the minimum necessary files to create a workable version of the document into a different folder.在尝试按照@JosefZ 的建议创建可复制的示例时,我从原始存储库中复制并粘贴了最少必要的文件,以将文档的可用版本创建到不同的文件夹中。 Thus, I did not copy the output folder (which in this case is "docs").因此,我没有复制 output 文件夹(在本例中为“docs”)。 By doing this the problem was gone.通过这样做,问题就消失了。 So, I deleted the output folder in the original repo and rebuilt the whole book again.所以,我删除了原始仓库中的 output 文件夹,并重新构建了整本书。 This solved the problem and now it is rendering correctly.这解决了问题,现在它可以正确渲染了。

Bottom line: When switching from git_book to bs4_book , make sure to delete the output folder (where the html files go), and rebuild the whole thing.底线:git_book切换到bs4_book时,请确保删除 output 文件夹(html 文件所在的位置),然后重建整个内容。

Thanks.谢谢。 Best,最好的,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM