R.Andres Castaneda
R.Andres Castaneda

Reputation: 780

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). You can see the current live version in this page and the repository here. image

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")

When I render the book in bs4_book I got the following messages that I did not get before with 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,

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"

Upvotes: 2

Views: 339

Answers (2)

Moritz Schwarz
Moritz Schwarz

Reputation: 2489

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.

This discussion on GitHub resolved it for me though.

The solution was to install the bookdown version from Pull Request #1027 where Hadley fixed this.

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.

Upvotes: 2

R.Andres Castaneda
R.Andres Castaneda

Reputation: 780

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. Thus, I did not copy the output folder (which in this case is "docs"). By doing this the problem was gone. So, I deleted the output folder in the original repo and rebuilt the whole book again. 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.

Thanks. Best,

Upvotes: 0

Related Questions