-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Code Handout #44
Comments
The first step would be a proof of concept that this works. Initially, all the exercises could be in a single file if it's easier. We can worry about splitting them into multiple files and figuring out their naming later. |
I took some time to sit down and actually work on this for ~10 minutes and found a solution using a modified pandoc lua filter: -- creates a handout from an article, using its headings,
-- blockquotes, numbered examples, figures, and any
-- Divs with class "handout"
function Pandoc(doc)
local hblocks = {}
for i,el in pairs(doc.blocks) do
if (el.t == "Div" and el.classes[1] == "challenge") then
for i,bl in pairs(el.content) do
if (bl.t == "Div" and bl.classes[1] == "solution") then
table.remove(el.content, i)
end
end
table.insert(hblocks, el)
end
end
return pandoc.Pandoc(hblocks, doc.meta)
end
|
It turns out that this solution can only be implemented on the rendered markdown. The reason why is because code blocks like this get interpreted as inline code and subsequently turns all newlines into single spaces:
Because R markdown strips all non-pandoc attributes from the file, we would need to add a knitr hook that captures the
|
Another alternative is via {pegboard} to add a method that will trim all content except challenges and code with the |
Overview
Extract content from the challenge blocks and translate them to code blocks for each episode.
A concept has been applied to Data Carpentry R Ecology lesson: https://github.com/datacarpentry/R-ecology-lesson/blob/main/make_code_handout.R, but it extracts EVERYTHING </Gary Oldman Voice>.
each exercise should be in its own file
Learners have a document that they can fill out as they go along. (see R ecology DC lesson). This also potentially allow new usage as “magic cells” and code slides.
Magic cells
This is a concept in Jupyter notebooks that allows people to load code into a cell using a single command.
Dr. Sarah Brown presented a poster on magic cells during CarpentryCon 2018 she also provided a repository containing examples.
Time of extraction
These should be created automagically on lesson rendering via pandoc lua filters.
The text was updated successfully, but these errors were encountered: