Skip to content

Commit

Permalink
Since rstudio#127, the callbacks registered using the websocket metho…
Browse files Browse the repository at this point in the history
…d $onClose() are not run when async=FALSE. I don't understand why.

The same result could have been obtained with `on.exit(close_ws(), add = TRUE, after = FALSE)` but the `after` argument is quite recent (R 3.5.0), I prefer to avoid it for backward compatibility with R < 3.5.0.
  • Loading branch information
RLesur committed Dec 16, 2019
1 parent d96b5e2 commit 329dc3d
Show file tree
Hide file tree
Showing 3 changed files with 10 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: pagedown
Type: Package
Title: Paginate the HTML Output of R Markdown with CSS for Print
Version: 0.6.3
Version: 0.6.4
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
person("Romain", "Lesur", role = c("aut", "cph"), comment = c(ORCID = "0000-0002-0721-5595")),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

- Using RStudio, any R Markdown HTML output formats can be directly printed to PDF by adding the line `"knit: pagedown::chrome_print"` to the YAML header: this line modifies the behavior of the "Knit" button of RStudio and produce both HTML and PDF documents.

## BUG FIXES

- In `chrome_print()` with `async = FALSE`, the Chrome processus and the local web server are properly closed when the function exits. This regression was introduced in **pagedown** 0.6.

# CHANGES IN pagedown VERSION 0.6

## MINOR CHANGES
Expand Down
6 changes: 5 additions & 1 deletion R/chrome.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ chrome_print = function(
}

t0 = Sys.time(); token = new.env(parent = emptyenv())
on.exit(close_ws())
on.exit({
close_ws()
kill_chrome()
if (!is.null(svr)) stop_server()
})
print_page(ws, url, output2, wait, verbose, token, format, options, selector, box_model, scale, res_fun, rej_fun)

if (async) {
Expand Down

0 comments on commit 329dc3d

Please sign in to comment.