Skip to content

Commit

Permalink
on Windows, we may need to encode the stdout of system2() as UTF-8 to…
Browse files Browse the repository at this point in the history
… correctly get the path of the newly created post file

this should fix the problem reported at https://d.cosx.org/d/422702
  • Loading branch information
yihui committed Nov 4, 2021
1 parent 75fd15b commit e4a3f38
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: blogdown
Type: Package
Title: Create Blogs and Websites with R Markdown
Version: 1.5.3
Version: 1.5.4
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Christophe", "Dervieux", role = "aut", email = "[email protected]", comment = c(ORCID = "0000-0003-4474-2498")),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

- `install_hugo()` stopped working with Hugo v0.89.0 (thanks, @martinolmos, #664).

- On Windows, `new_post()` may fail to open the new post if the filename contains multibyte characters (thanks, yingjie, https://d.cosx.org/d/422702).

# CHANGES IN blogdown VERSION 1.5

## NEW FEATURES
Expand Down
4 changes: 3 additions & 1 deletion R/hugo.R
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,10 @@ new_content = function(path, kind = '', open = interactive()) {
stdout = TRUE
)
if (length(i <- grep(r <- ' created$', file2)) == 1) {
file2 = sub(r, '', file2[i])
file2 = sub(r, '', file2[i], useBytes = TRUE)
if (!grepl('[.]md$', file2)) file2 = file.path(file2, 'index.md')
# on Windows, we may need to encode the stdout of system2() as UTF-8
if (!file_exists(file2)) Encoding(file2) = 'UTF-8'
} else {
# should the above method fail to identify the newly created .md, search for
# the new file with brute force
Expand Down

0 comments on commit e4a3f38

Please sign in to comment.