Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fallback to parse usual R comments in Quarto #2225

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion R/parser.R
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,24 @@ partition_chunk = function(engine, code) {
# check for option comments
i1 = startsWith(code, s1)
i2 = endsWith(trimws(code, 'right'), s2)
m = i1 & i2

# if "commentChar| " is not found, try "#| " instead
if (!i1[1] && !identical(s1, '#|')) {
s1 = '#| '; s2 = ''
i1 = startsWith(code, s1); i2 = TRUE
m = i1 & i2
# if found in quarto, stop and advice to use language comment
if (is_quarto() && m[[1]]) {
stop2(c(
"Non R chunk should prefix pipe `|` with the comment character from the language for YAML options. ",
sprintf("You are using %s:\n", sQuote(engine)),
sprintf(" you probably should start your comment with %s", dQuote(s1)),
if (nzchar(s2)) sprintf(" and use %s at end of each comment line.", dQuote(s2)),
"\n"
))
}
}
m = i1 & i2

# has to have at least one matched line at the beginning
if (!m[[1]]) return(res)
Expand Down