Format a ts_tree object for printing.
Usage
# S3 method for class 'ts_tree'
format(x, n = 10, ...)Details
This is the engine of print.ts_tree(),
possibly useful to obtain a printed representation without doing the
actual printing.
If there are selected nodes in the tree, those will be highlighted
in the output. See ts_tree_select() to
select nodes in a tree.
Examples
# Create a parse tree with tsjsonc -------------------------------------
json <- tsjsonc::ts_parse_jsonc(
'{ "a": 1, "b": [10, 20, 30], "c": { "c1": true, "c2": 100 } }'
)
format(json)
#> [1] "\033[90m# jsonc (1 line)\033[39m"
#> [2] "\033[90m1\033[39m\033[90m | \033[39m{ \"a\": 1, \"b\": [10, 20, 30], \"c\": { \"c1\": true, \"c2\": 100 } }"