Skip to contents

Determines the XML children node indices for every XML node at the highest level of xml by interpreting Markdown heading levels (1–6).

Usage

md_xml_subnode_ix(xml)

Arguments

xml

CommonMark parse tree. An xml_document, xml_nodeset or xml_node.

Value

A list of integer vectors of the same length as the number of XML nodes at the highest level of xml.

Details

commonmark::markdown_xml() (and so md_to_xml() which builds upon it) do parse (R) Markdown file content according to the CommonMark specification, but do not return any information about the document's heading hierarchy. md_xml_subnode_ix() fills this gap by giving the hierarchy structure in the form of the XML subnode indices for every node at the highest level of xml.

See also

Other CommonMark parsing functions: md_to_xml(), xml_to_md()

Examples

"# A title

Some prose.

## A subtitle

More prose.

## Another subtitle

Out of prose here.

### A sub-subtitle

I'm dug in.

# Another title

A last word." |>
  pal::md_to_xml() |>
  pal::md_xml_subnode_ix()
#> [[1]]
#> [1] 2 3 4 5 6 7 8
#> 
#> [[2]]
#> integer(0)
#> 
#> [[3]]
#> [1] 4
#> 
#> [[4]]
#> integer(0)
#> 
#> [[5]]
#> [1] 6 7 8
#> 
#> [[6]]
#> integer(0)
#> 
#> [[7]]
#> [1] 8
#> 
#> [[8]]
#> integer(0)
#> 
#> [[9]]
#> [1] 10
#> 
#> [[10]]
#> integer(0)
#>