Find and protect all inline math elements
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")
#>
#> This sentence contains $I\_A$ $\\frac{\\pi}{2}$ inline $\\LaTeX$ math.
#>
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")
}
#>
#> This sentence contains $I_A$ $\frac{\pi}{2}$ inline $\LaTeX$ math.
#>