Navigation Menu

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

White space breaks chunk regexes? #236

Closed
jamiefolson opened this issue May 16, 2012 · 5 comments
Closed

White space breaks chunk regexes? #236

jamiefolson opened this issue May 16, 2012 · 5 comments
Labels
feature Feature requests
Milestone

Comments

@jamiefolson
Copy link

Not sure if this is desired, but if there's any whitespace in front of a chunk, it's not detected, e.g. " <<>>=...@" instead of "<<>>=...2"

@yihui
Copy link
Owner

yihui commented May 17, 2012

this is the default syntax inherited from Sweave, and I guess the main consideration is to make it as unique as possible because it serves as the marker of code chunks

you can customize the syntax like this (see http://yihui.name/knitr/patterns):

library(knitr)
pat_rnw()  # default syntax
knit_patterns$set(chunk.begin = "^\\s*<<(.*)>>=", chunk.end = "^\\s*@\\s*%*")

\\s* means white spaces.

Is there a special reason that you need to add white spaces before <<>>=?

@yihui yihui closed this as completed in e6a124f May 23, 2012
@vspinu
Copy link

vspinu commented Jun 6, 2012

Hi Yihui,

I have started looking into knitr to find ways to integrate into ESS. So far I am really impresed. Thanks for your work. Be sure that we will have a full blown support for knitr in the next version (September I guess).

This issue is crucial for proper indentation of code chunks inside Latex docs when chunks are not at top level.

For example you might want to have a chunk inside itemize environment and to indent the code according to latex rules. Would be good to allow spaces in front of << and @ by default.

@yihui
Copy link
Owner

yihui commented Jun 6, 2012

Actually I believe this is a fair request now, because sometimes I also want the code blocks to be indented, especially in markdown. White spaces do not really have any influence on LaTeX output, but they do have a meaning for markdown. So I think I will change the syntax to allow white spaces before << and @.

I'm thrilled to know knitr is going to ESS. Thanks!

@yihui
Copy link
Owner

yihui commented Aug 6, 2012

hi @jamiefolson and @Vitoshka,

now leading spaces are allowed in chunk headers, so you are free to indent the chunks; see https://github.com/yihui/knitr/blob/master/NEWS.md#major-changes

@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
feature Feature requests
Projects
None yet
Development

No branches or pull requests

3 participants