-
-
Notifications
You must be signed in to change notification settings - Fork 879
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
knit() cannot handle variable numbers of backticks #1621
Comments
I don't think this particular case will be too complicated to fix. You may take a look at However, even with that fix, it still won't work for this case (four backticks in the string): ````{r}
x <- "
````
"
```` |
Oh, thanks. Maybe I thought too much. That case doesn't seem supposed to work because it's not a valid markdown...? |
Well, it is valid Markdown: it is a code block with |
Sorry, this is valid as Markdown / R Markdown. What I meant to say was
Sorry, I don't get your point. Do you think knitr's parser should parse this as a code block of the below instead of x <- "
````
" |
Yes. Well, maybe. I don't really know. Perhaps it should just fail. There isn't a right answer here. Users could write an R code chunk with incomplete R code, e.g.,
And the output will be So I guess we can ignore the edge case I first mentioned, and only fix the original issue you brought forward. |
I believe it should fail; R Markdown itself should not be aware of code inside chunks because the code is not always written in R. That said, after some thinking, now I feel you are right in that it's nice if knitr can detect these mistakes and raise a helpful error message :) |
I tried to solve this problem.
|
The fix master...atusy:1621 seems to be on the right track to me. I didn't read it carefully or test it.
I'm not sure what that means, but the output blocks will intelligently use N+1 backticks when N backticks are detected in the output: Lines 157 to 162 in 7d2dd40
|
@yihui Oh thanks for hint. I'll see if I can implement simply with your trick (maybe next weekend) |
Thanks for fixing!!! 🎉 |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
(Originally reported here: rstudio/rmarkdown#1444 (comment))
spin()
now uses various number of backticks (#1611), but currentlyknit()
cannot handle them.Created on 2018-10-10 by the reprex package (v0.2.1)
To determine how many backticks are used to represent the end of a chunk, we need to look at the beginning of the chunk (in actual, the rule is a bit more complex). But, in the current implementation of
split_file()
, begin chunks and end chunks are matched separately, so it seems difficult to fix without introducing a big change to the current implementation.knitr/R/parser.R
Lines 15 to 16 in 3abb642
The text was updated successfully, but these errors were encountered: