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 syntax #69

Open
rundel opened this issue Aug 17, 2020 · 2 comments
Open

knitr syntax #69

rundel opened this issue Aug 17, 2020 · 2 comments

Comments

@rundel
Copy link

rundel commented Aug 17, 2020

I've been working on a parser for RMarkdown documents using Boost's Spirit X3 library. I'm currently using the Rmds available within this repo as a test set to make sure my code is working correctly.

In running my parser I've come across some potential typos and inconsistencies in syntax in the example documents and I wanted to clarify.

Mismatched backticks

Chunk begins with 3 backticks and ends with 4, it seems like knitr is not checking for balance between the backticks as long as there is >= 3. Oddly, for the document below RStudio gives me an unexpected token error via the linter but I don't see a similar error when creating my own test documents.

Chunks missing closing backticks

There are a couple of examples where there are two sequential chunks where the first is missing its closing backticks, but it is immediately followed by the start of a new chunk. The documents compile correctly but this seems wrong to me.

Chunks with engine and name separated by a comma

There are several documents where the chunk has a format that looks like

```{engine, name, opt=val}

my understanding is that the prefered format should be

```{engine name, opt=val}

is the former syntax allowable?

yihui added a commit that referenced this issue Aug 17, 2020
@yihui
Copy link
Owner

yihui commented Aug 17, 2020

Chunk begins with 3 backticks and ends with 4, it seems like knitr is not checking for balance between the backticks as long as there is >= 3.

That's true. I just fixed the example anyway.

There are a couple of examples where there are two sequential chunks where the first is missing its closing backticks, but it is immediately followed by the start of a new chunk.

Closing backticks are not required before a new code chunk is opened. That's from Knuth's literate programming. Section 5.1.4 has more info about it: https://www.google.com/books/edition/Dynamic_Documents_with_R_and_knitr/fyIuDwAAQBAJ?hl=en&gbpv=1&bsq=%20literate%20programming

Chunks with engine and name separated by a comma

Either a comma or a space can serve as the separator.

Thank you!

@rundel
Copy link
Author

rundel commented Aug 18, 2020

Closing backticks are not required before a new code chunk is opened. That's from Knuth's literate programming. Section 5.1.4 has more info about it: https://www.google.com/books/edition/Dynamic_Documents_with_R_and_knitr/fyIuDwAAQBAJ?hl=en&gbpv=1&bsq=%20literate%20programming

Interesting, I wasn't familiar with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants