Skip to content

Commit

Permalink
fix: error on generating description from a long sentence (#1463)
Browse files Browse the repository at this point in the history
  • Loading branch information
atusy authored Apr 3, 2024
1 parent 50a1c1e commit 65aed2a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: bookdown
Type: Package
Title: Authoring Books and Technical Documents with R Markdown
Version: 0.38.1
Version: 0.38.2
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Christophe", "Dervieux", , "[email protected]", role = c("ctb"),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CHANGES IN bookdown VERSION 0.39


- Fixed a bug that `bs4_book()` errors on generating document description. The error occured when the beggining of the document is a very long sentence without spaces (> 197 characters), which typically happens in CJK languages (thanks, @atusy, #1463).

# CHANGES IN bookdown VERSION 0.38

Expand Down
2 changes: 1 addition & 1 deletion R/bs4_book.R
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ tweak_metadata <- function(html, path) {
if (nzchar(text)) {
words <- unlist(strsplit(text, " "))
no_char <- cumsum(unlist(lapply(words, function(x) {nchar(x) + 1})))
max_n <- max(which(no_char<= 197))
max_n <- max(which(no_char <= 197), 1)
description_string <- paste(words[1: max_n], collapse = " ")
if (max_n != length(words)) {
description_string <- paste0(description_string, "...")
Expand Down

0 comments on commit 65aed2a

Please sign in to comment.