Overrides the $ operator so the content and attributes of
md_node objects can be read and updated by name. Use node$content to
access or replace the children of a block or span node (or the text of a
text node), and node$<attr> to read or update an existing node attribute
(e.g. level, href, mark).
Only attributes already present on the node may be replaced, and the new
value is validated against the same rules used by the corresponding
md_block_* / md_span_* constructor. The class and names attributes
cannot be set this way.
# S3 method for class 'md_node'
x$name
# S3 method for class 'md_node'
x$name <- value
# S3 method for class 'md_text'
x$name <- valueA modified md_node object.
md = md_text_normal("Hello World")
md$content = "Nice to meet you"
md
#> md_text_normal - "Nice to meet you"
md = md_block_ul(
md_block_li(md_text_normal("bullet 1")),
md_block_li(md_text_normal("bullet 2"))
)
md$mark = "-"
md$content[[1]]$content[[1]]$content = "first"
to_md(md) |> cat(sep = "\n")
#> - first
#> - bullet 2