make_div_pairs | R Documentation |
Native and fenced divs may have several tags grouped in a single element. In order to mark the pairs, we need to account for what tags exist in the nodes. This function creates that
make_div_pairs(nodes, path = NULL, yaml = NULL)
nodes |
a nodelist containing native div and fenced div tags in
|
a list of data frames for each node with the following columns:
node: numeric index of the node
div: the text of the individual div element, stripped of context
label: label of the div pair (div-label-class)
pos: position the label will be relative to its associated node
Other div:
clean_div_tags()
,
find_between_tags()
,
find_div_pairs()
,
get_divs()
,
label_div_tags()
,
label_pairs()
,
make_div()
,
replace_with_div()
txt <- "# Example with a mix of div tags
> PLEASE NEVER DO THE LESSONS THIS WAY
>
> I AM LITERALLY JUST TESTING A TERRIBLE EXAMPLE.
--------------------------------------------------------------------------------
<div class='challenge'>
## Challenge
do that challenging thing.
```{r}
cat('it might be challenging to do this')
```
:::: solution
```{r}
It's not that challenging
```
:::
<div class='solution'>
We just have to try harder and use `<div>` tags
:::::: callout
```{r}
cat('better faster stronger with <div>')
```
::::
:::::: discussion
<img src='https://carpentries.org/logo.svg'/>
:::::
</div>
</div>
<div class='good'>
## Good divs
</div>
"
tmp <- tempfile()
writeLines(txt, tmp)
ex <- tinkr::to_xml(tmp)
pegboard:::clean_div_tags(ex$body)
nodes <- pegboard:::find_div_tags(ex$body)
divs <- pegboard:::make_div_pairs(nodes)
do.call("rbind", divs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.