div_labels: Add labels to div tags in the form of a "dtag" node with a...

label_div_tagsR Documentation

Add labels to div tags in the form of a "dtag" node with a paired "label" attribute.

Description

Add labels to div tags in the form of a "dtag" node with a paired "label" attribute.

Usage

label_div_tags(body)

find_div_tags(body)

clear_div_labels(body)

Arguments

body

an xml document

Value

  • label_div_tags(): the document, modified

  • clear_div_labels(): the document, modified

  • find_div_tags(): a node list

See Also

Other div: clean_div_tags(), find_between_tags(), find_div_pairs(), get_divs(), label_pairs(), make_div(), make_div_pairs(), replace_with_div()

Examples

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)
ex$body
pegboard:::label_div_tags(ex$body)
ex$body
pegboard:::clear_div_labels(ex$body)

carpentries/pegboard documentation built on Nov. 13, 2024, 8:53 a.m.