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

Add highlight.source to select highlighted line for remarkjs #309

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented Apr 23, 2021

@gadenbuie here is what I tried so far quickly today.

It makes this work

---
output:
  xaringan::moon_reader:
    lib_dir: libs
    nature:
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
---

```{r include=FALSE}
library(DBI)
con <- dbConnect(RSQLite::SQLite(), dbname = ":memory:")
foo <- dbExecute(con, "DROP TABLE IF EXISTS packages")
foo <- dbExecute(con, "CREATE TABLE packages (id INTEGER, name TEXT)")
foo <- dbExecute(con, "INSERT INTO packages VALUES (1, 'readr'), (2, 'readxl'), (3, 'haven')")
```


## SQL

```{sql, connection = con, highlight.source = c(2)}
SELECT * 
FROM packages
```

but if used for R engine or other with chunk that contains more that one expression to evaluate, the index won't be ok. This for example means 2 source blocks and 2 output blocks

```{r}
x <- 1
x
x + 2
```

using collapse = TRUE would also mix things up.

So translating the numeric index indexing passed by the user as seen in the source to the one after evaluation is trickier. It may need to be calculated earlier in the hook.

Just sharing here as draft so that you see what I tried 😉

@cderv cderv linked an issue Apr 23, 2021 that may be closed by this pull request
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

Successfully merging this pull request may close these issues.

Highlighting code lines in evaluated SQL-expressions
1 participant