This PR improves QOL for people subsetting documents by allowing them to see the context of the nodes they create.
I'm not terribly set on the names, but I've got:
show_list() which shows each element in its own paragraph
show_block() which shows each element in its own context, with other contexts stripped away
adding mark = TRUE adds markers indicating if there was context preceding or following
show_censor() shows the nodes in the full context, censoring the other nodes visually.
I've also included to_md_vec(), allowing users to get markdown vectors from nodelists, which is useful for things like headings that contain markdown elements.
I'm hoping to include this as tinkr 0.3.0 (which does not include #107)
# extract the level 3 headers from the body
headers3 <- xml2::xml_find_all(
yaml_xml_list$body,
xpath = './/md:heading[@level="3"]',
ns = md_ns()
)
# show the headers
print(h3 <- to_md_vec(headers3))
#> [1] "### Getting a list of 50 species from occurrence data"
#> [2] "### Querying the scientific literature"
#> [3] "### Querying scientific open data"
#> [4] "### Conclusion"
# show the items in their local structure
show_block(items)
#>
#>
#> - kittens
#> - are
#> - super
#> - cute
#> - have
#> - teef
#> - murder mittens
#> - brains
#> - are
#> - wrinkly
# You can also adjust the censorship parameters. There are two paramters
# available: the mark, which chooses what character you want to use to
# replace characters (default: `\u2587`); and the regex which specifies
# characters to replace (default: `[^[:space:]]`, which replaces all
# non-whitespace characters.
#
# The following will replace everything that is not a whitespace
# or punctuation character with "o" for a very ghostly document
op <- options()
options(tinkr.censor.regex = "[^[:space:][:punct:]]")
options(tinkr.censor.mark = "o")
show_censor(links)
This PR improves QOL for people subsetting documents by allowing them to see the context of the nodes they create.
I'm not terribly set on the names, but I've got:
show_list()
which shows each element in its own paragraphshow_block()
which shows each element in its own context, with other contexts stripped awaymark = TRUE
adds markers indicating if there was context preceding or followingshow_censor()
shows the nodes in the full context, censoring the other nodes visually.I've also included
to_md_vec()
, allowing users to get markdown vectors from nodelists, which is useful for things like headings that contain markdown elements.I'm hoping to include this as tinkr 0.3.0 (which does not include #107)
to_md_vec()
Created on 2024-06-14 with reprex v2.1.0
Show Functions
Created on 2024-06-14 with reprex v2.1.0