clean_fenced_divs: Clean pandoc fenced divs and place them in their own...

View source: R/div.R

clean_fenced_divsR Documentation

Clean pandoc fenced divs and place them in their own paragraph elements

Description

Sometimes pandoc fenced divs are bunched together, which makes it difficult to track the pairs. This separates them into different paragraph elements so that we can track them

Usage

clean_fenced_divs(body)

Arguments

body

an xml document

Value

an xml document

Note

DEPRECATED.

Examples

txt <- "::::::: challenge
## Challenge

do that challenging thing.

```{r}
cat('it might be challenging to do this')
```
::::: solution ::::
```{r}
It's not that challenging
```
::::
::: solution ::::::::
We just have to try harder and use `<div>` tags

```{r}
cat('better faster stronger with <div>')
```
<img src='https://carpentries.org/logo.svg'/>

What if we include some `:::` code in here or ::: like this

:::::
:::::

::: good

## Good divs

:::"
f <- tempfile()
writeLines(txt, f)
ex <- tinkr::to_xml(f, sourcepos = TRUE)
ex$body
predicate <- ".//d1:paragraph/d1:text[starts-with(text(), ':::')]"
xml2::xml_text(xml2::xml_find_all(ex$body, predicate))
pegboard:::clean_fenced_divs(ex$body)
xml2::xml_text(xml2::xml_find_all(ex$body, predicate))

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