Skip to content

Commit

Permalink
retrieve default chunk options comment and attr.output from xfun:…
Browse files Browse the repository at this point in the history
…:raw_string() if possible: yihui/xfun@f195d0e
  • Loading branch information
yihui committed Jan 10, 2025
1 parent 9cc3f9c commit 092d392
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: litedown
Type: Package
Title: A Lightweight Version of R Markdown
Version: 0.5.3
Version: 0.5.4
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666", URL = "https://yihui.org")),
person("Tim", "Taylor", role = "ctb", comment = c(ORCID = "0000-0002-8587-7113")),
Expand Down
11 changes: 8 additions & 3 deletions R/fuse.R
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,13 @@ fuse_code = function(x, blocks) {
} else {
if (type == 'message') x = sub('\n$', '', x)
if (!asis) {
x = split_lines(x)
x = paste0(opts$comment, x) # comment out text output
opt2 = attr(x, 'opts')
cmt = opts$comment %||% opt2$comment %||% '#> '
if (cmt != '') {
x = split_lines(x)
x = paste0(cmt, x) # comment out text output
}
if (is.null(a)) a = opt2$attr
}
}
if (asis) {
Expand Down Expand Up @@ -992,7 +997,7 @@ new_opts = function() {
#' ls(opts) # built-in options
reactor = new_opts()
reactor(
eval = TRUE, echo = TRUE, results = TRUE, comment = '#> ',
eval = TRUE, echo = TRUE, results = TRUE, comment = NULL,
warning = TRUE, message = TRUE, error = NA, include = TRUE,
strip.white = TRUE, collapse = FALSE, order = 0,
attr.source = NULL, attr.output = NULL, attr.plot = NULL, attr.chunk = NULL,
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ counters = local({

# use PCRE by default (which seems to handle multibyte chars better)
gregexpr = function(..., perl = TRUE) base::gregexpr(..., perl = perl)

attr = function(...) base::attr(..., exact = TRUE) # exact attr() please
`%|%` = function(x, y) if (length(x)) x else y
if (getRversion() < '4.4.0') `%||%` = function(x, y) if (is.null(x)) y else x
set_names = function(x, nm) {
Expand Down

0 comments on commit 092d392

Please sign in to comment.