Closed ismayc closed 7 years ago
Hey @ismayc,
basically, the tutorial
package converts your R Markdown chunks into html that DataCamp Light understands, and then includes a <script>
tag to the top of the document to import the datacamp light javascript library:
<script src=https://cdn.datacamp.com/datacamp-light-latest.min.js></script>
It appears that bookdown
does some magic with the HTML content and the scripts to split up the content into different pages for each chatper. The script
tag that refers to datacamp light is lost in translation. If you just update your example as follows:
---
title: "Example Document"
author: "Your name here"
output:
bookdown::gitbook
---
# Chap 1
<script src=https://cdn.datacamp.com/datacamp-light-latest.min.js></script>
## Sec 1
```{r, include=FALSE}
tutorial::go_interactive(greedy=FALSE)
```
By default, `tutorial` will convert all R chunks.
```{r tut=TRUE}
a <- 2
b <- 3
a + b
```
(so basically hardcoding the script tag in each chapter), the blocks should render fine. It's possible that you might have to do some CSS tweaking to not have the themes interfere with the datacamp light css to render the chunks; that's an open issue on the datacamp-light project.
I could also solve this in tutorial
itself, by automatically including the <script>
tag before every datacamp light chunk I include, but that would mean including the script potentially dozens of times, which is not good practice.
I hope this answers your question!
@ismayc did it work?
It is working! Thanks, @filipsch. I'm not quite sure that I want to go through copying all of the questions from my DataCamp course into the book though on second thought, especially with the chunk syntax being a little different.
{r ex="joining-data-frames", type="pre-exercise-code", tut=TRUE}
versus
--- type:NormalExercise lang:r xp:100 skills:1 *** =pre_exercise_code
Does the DataCamp syntax work on DataCamp Light or vice versa? Or is there a way to reference problems on DataCamp already for use in DataCamp Light?
Also, it appears the links at the bottom of https://cran.r-project.org/web/packages/tutorial/vignettes/tutorial-basics.html are no longer active as they just route to the DataCamp course.
@ismayc Unfortunately, it's not yet possible to 'port' DataCamp Light-formatted exercises to regular DataCamp exercises or vice versa. The big difference is that the DataCamp exercises live in DataCamp's database, while for DCL, they just exist in the web page.
I think it should be possible, though, to be able to reference an exercise, so it can be fetched from the database, and then have a tutorial helper function generate a DataCamp light version of it; that shouldn't be too hard. I'll open up a new issue for that.
About the links: thanks, good find, i'll update that in the next version of tutorial
.
When you have split-by: section
does not work adding the Githubissues.
I'm hoping to add some exercises to a
bookdown
book, but am not getting the R Markdown chunks to render in the HTML file. All that I get is something like this in the HTML fileThe Rmd I am using is at https://gist.github.com/ismayc/5e8c046a7e7bdaafbaba2db2be8eae94 .
It appears that adding in the chapter headers via # is what causes the chunk to just produce the text instead of the DataCamp window.
Here is my session info: