rundel / parsermd

https://rundel.github.io/parsermd/
Other
76 stars 4 forks source link

Code chunks with empty attributes fail to parse #28

Open gadenbuie opened 2 years ago

gadenbuie commented 2 years ago

Bit of an odd case that I just ran into. A chunk with an empty set of braces

```{}
# example code

is parsed as a plain code block by pandoc/rmarkdown

``` r
text <-  c(
  "```{}", 
  "# example code", 
  "```"
)

withr::with_tempfile("tf", {
  writeLines(knitr::knit(text = text), tf)
  rmarkdown::pandoc_convert(tf, from = "markdown", to = "html")
})
#> <pre><code># example code</code></pre>

but is flagged as invalid syntax by parse_rmd().

parsermd::parse_rmd(text)
#> Error: Failed to parse line 1, expected chunk engine
#> ```{}
#> ~~~~^
rundel commented 2 years ago

I think there should be an approach that handles this and #27 using a look ahead - I'll play around with it and see what I can get working