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
fixes #252: Allow plain-code-blocks in RMarkdown #349
Conversation
Added a test to the end of test.Rmd that included a plain-code-block like this: ``` This shouldn't cause a problem ``` The code-block reproduced the `Malformed File` error described in #252 Plain-blocks match the knitr `chunk.end` pattern at both the start and the end of the block. So when plain-blocks are present there was 2k _more_ chunk ends than starts. A small function `filter_chunk_end_positions` was added to filter the positions of the chunk-ends based on the chunk-starts
not the most beautiful way to find the blocks, but I beleive it would work. |
Thanks! Could you add a
example like in #322 as well to the Rmd. Also please add a note to NEWS.md explaining the change and referencing the issue number and your GitHub username. |
Is it OK if I work on the @randy3k - if you have a suggestion for a more idiomatic way to match the start/end positions I'm happy to modify the code; my first attempt wasn't even this beautiful ... |
Have updated |
For consistency with the other helper functions in |
Sure that makes sense, thanks! |
Main function `extract_r_source` now precedes all it's helper functions (get_knitr_pattern, filter_chunk_end_positions, replace_prefix)
Added a test to the end of test.Rmd that included a plain-code-block like this:
That is, a code-block where the interpreter is not specified (these are allowable in Rmarkdown according to section 2.5.2 of Yihui's Rmarkdown book).
The code-block reproduced the
Malformed File
error described in issue #252Plain-blocks match the knitr
chunk.end
pattern at both the start and the endof the chunk. So when plain-blocks are present there was an extra 2k chunk ends
than starts.
A small function
filter_chunk_end_positions
was added to filter the positionsof the chunk-ends based on the chunk-starts and called from
extract_r_source