Extracts the paragraphs of the main content of a page, each with the last
heading above it. Use it when the page is known and a selector can target
its body. read_html_blocks() reads a whole saved file instead.
Details
Nested matches (a <p> inside a <li>) would duplicate text, so that only
the innermost text-bearing elements are kept.
See also
Other html:
html_text_or_na(),
prefer_html_text(),
read_html_blocks()
Examples
page <- xml2::read_html(
"<main><h2>Intro</h2><p>First.</p><ul><li>Item.</li></ul></main>"
)
html_paragraphs(page, "main")
#> paragraph section text
#> <int> <char> <char>
#> 1: 1 Intro First.
#> 2: 2 Intro Item.