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

knitr adds ' --- ' to chunk names in external file, if 4 spaces follow #606

Closed
jhmaindonald opened this issue Sep 18, 2013 · 4 comments
Closed
Labels
bug Bugs
Milestone

Comments

@jhmaindonald
Copy link

read_chunk("scripts/maps-code.R")
z<-knitr:::knit_code$get()
names(z)[16:18]
[1] "sp27-read" "sp27-spplot ----" "meuse-bubble ----"

For names 17 and 18, the line ended with '---- ', i.e. there
were four spaces at the end.

Why did 4 spaces get there. In RStudio version 0.98_308, as in the previous
development version, typing the 'Enter' key in a code file takes one, not to the
beginning of the next line, but to the end of a line that has four spaces.
(This, even though I turned off 'Auto-indent code after paste' under the Code
Editing option.) Before typing on a new line, I navigated to the start of the
line, without deleting the spaces.

I am using knitr_1.4.1

@jhmaindonald
Copy link
Author

Actually, 1 space following the final '----' is enough to trigger the problem.
I have not tried other possibilities, e.g., '-- '.

It would be worth mentioning the use of knitr:::knit_code$get() in documents
that describe code externalization. It is a vital aid for checking out issues
with the input of external code chunks.

@jhmaindonald
Copy link
Author

A further note. What I identified as an RStudio issue (the initial
reason for the 4 spaces) arose because I'd accidentally
created an uncompleted code line in an earlier code chunk.

@jhmaindonald jhmaindonald reopened this Sep 18, 2013
@yihui yihui closed this as completed in 06b229a Sep 20, 2013
@yihui
Copy link
Owner

yihui commented Sep 20, 2013

should be fixed now; thanks!

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bugs
Projects
None yet
Development

No branches or pull requests

2 participants