protect_inline_math: Find and protect all inline math elements

View source: R/asis-nodes.R

protect_inline_mathR Documentation

Find and protect all inline math elements

Description

Find and protect all inline math elements

Usage

protect_inline_math(body, ns)

Arguments

body

an XML document

ns

an XML namespace

Value

a modified copy of the original XML document

Examples

txt <- commonmark::markdown_xml(
  "This sentence contains $I_A$ $\\frac{\\pi}{2}$ inline $\\LaTeX$ math."
)
txt <- xml2::read_xml(txt)
cat(tinkr::to_md(list(body = txt, yaml = "")), sep = "\n")
ns  <- tinkr::md_ns()
if (requireNamespace("withr")) {
protxt <- withr::with_namespace("tinkr", protect_inline_math(txt, ns))
cat(tinkr::to_md(list(body = protxt, yaml = "")), sep = "\n")
}

ropensci/tinkr documentation built on April 23, 2024, 9:41 a.m.