Skip to content

Commit 817447d

Browse files
committed
close #102: treat the input # text to fuse() as Markdown instead of R code
1 parent 73e08f3 commit 817447d

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: litedown
22
Type: Package
33
Title: A Lightweight Version of R Markdown
4-
Version: 0.7.1
4+
Version: 0.7.2
55
Authors@R: c(
66
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666", URL = "https://yihui.org")),
77
person("Tim", "Taylor", role = "ctb", comment = c(ORCID = "0000-0002-8587-7113")),

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
- The chunk option `results = 'hide'` will imply `collapse = TRUE`, i.e., when text output is hidden, the source blocks will be merged (thanks, @jangorecki, #87).
44

5+
- `fuse(text = '# text')` will be treated as Markdown input instead of R code input (thanks, @chuxinyuan, #102).
6+
57
# CHANGES IN litedown VERSION 0.7
68

79
- `pkg_manual()` will exclude help pages with the keyword `internal` (thanks, @TimTaylor, #78).

R/utils.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ is_output_full = function(x) isTRUE(attr(x, 'full'))
163163
# test if input is R code or not (this is based on heuristics and may not be robust)
164164
is_R = function(input, text) {
165165
if (is_file(input)) grepl('[.][Rrs]$', input) else {
166-
!length(grep('^\\s*```+\\{', text)) && !try_error(parse_only(text))
166+
# if R code, it must not contain ```{, be syntactically valid, and contain
167+
# at least one expression (i.e., not all comments)
168+
!length(grep('^\\s*```+\\{', text)) && !try_error(res <- parse_only(text)) && length(res)
167169
}
168170
}
169171

0 commit comments

Comments
 (0)