Closed mdneuzerling closed 4 years ago
Oops, I'm applying my R highlighting to all engines, not just R. Should be an easy fix.
The same thing seems to happen with R code that doesn't parse. For example, if I have an R code chunk with eval = FALSE
that defines a function without a body (y <- function(x)
) then that will also be converted to NA
in the markdown.
That helped me narrow the issue down:
> downlit::highlight("y <- function(x) {x + 1}")
# [1] "<span class='k'>y</span> <span class='o'><-</span> <span class='nf'>function</span>(<span class='k'>x</span>) {<span class='k'>x</span> <span class='o'>+</span> <span class='m'>1</span>}"
> downlit::highlight("y <- function(x)")
# [1] NA
When I use languages other than R, the input sometimes appears as NA, although the output is unaffected. I've been able to replicate this with python, bash and scala.
In terms of a reproducible example, I've created a new hugodown site using the latest version of hugodown, and the function
create_site_academic()
. I created an R Markdown file with code chunks from these languages. I then knitted the markdown file which shows the NA inputs.I'm happy to give this issue a go and try to find the cause as best I can. Thus far I've tried using another machine (Windows, without the bash chunk), and disabling
link_inline
. I think a hint here is that in the Python code chunk,print("This is a python chunk")
isn't converted toNA
. I suspect this is because that line is also valid R code.