find_between | R Documentation |
Helper function to find all nodes between a standard pattern. This is useful if you want to find unnested pandoc tags.
find_between(
body,
ns,
pattern = "md:paragraph[md:text[starts-with(text(), ':::')]]",
include = FALSE
)
body |
and XML document |
ns |
the namespace of the document |
pattern |
an XPath expression that defines characteristics of nodes between which you want to extract everything. |
include |
if |
a nodeset
md <- glue::glue("
h1
====
::: section
h2
----
section *text* with [a link](https://ropensci.org/)
:::
")
x <- xml2::read_xml(commonmark::markdown_xml(md))
ns <- xml2::xml_ns_rename(xml2::xml_ns(x), d1 = "md")
res <- find_between(x, ns)
res
xml2::xml_text(res)
xml2::xml_find_all(res, ".//descendant-or-self::md:*", ns = ns)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.