protect_fences: Protect fences of Pandoc fences divs for further processing

View source: R/attr-nodes.R

protect_fencesR Documentation

Protect fences of Pandoc fences divs for further processing

Description

Protect fences of Pandoc fences divs for further processing

Usage

protect_fences(body, ns = md_ns())

Arguments

body

an XML object

ns

an XML namespace object (defaults: md_ns()).

Details

Commonmark will render text such as ⁠::: footer⁠ as normal text which might be problematic if trying to extract real text from the XML.

If sending the XML to, say, a translation API that allows some tags to be ignored, you could first transform the text tags with the attribute fences to fences tags, and then transform them back to text tags before using to_md().

Value

a copy of the modified XML object

Note

this function is also a method in the yarn object.

Examples

m <- tinkr::to_xml(system.file("extdata", "fenced-divs.md", package = "tinkr"))
xml2::xml_child(m$body)
m$body <- protect_fences(m$body)
xml2::xml_child(m$body)

tinkr documentation built on June 8, 2025, 10:30 a.m.