Skip to content

Commit

Permalink
amend f5c9d58: when s2 == '', i2 is a scalar, so i2[i] may contain NA…
Browse files Browse the repository at this point in the history
…s when i > 1
  • Loading branch information
yihui committed Nov 23, 2024
1 parent 7cb5e49 commit 6474e0e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/knitr.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ divide_chunk = function(engine, code) {
i = 1:n2; src = code[i]; code = code[-i]

# extract meta from comments, then parse it
meta = substr(src, nchar(s1) * i1[i] + 1, nchar(src) - nchar(s2) * i2[i])
c1 = nchar(s1) * i1[i] + 1
c2 = nchar(src) - if (s2 == '') 0 else nchar(s2) * i2[i]
meta = substr(src, c1, c2)
# see if the metadata looks like YAML or CSV
if (grepl('^[^ :]+:($|\\s)', meta[1])) {
meta = yaml_load(meta, envir = FALSE)
Expand Down

0 comments on commit 6474e0e

Please sign in to comment.