Convert markdown list into bigtree
jet10000 opened this issue · comments
* abc
* 123
* 456(name='test', age=10)
* efg
* opq
* rst
convert markdown to bigtree
@jet10000 Do you have a use case for this?
Hi, thanks for using bigtree
, this function from markdown/text to tree it already available in str_to_tree
method. However, it only converts the tree structure and will not be able to infer the node attributes (in your case, the name and age attributes) as the whole string will be interpreted as a node name.
Another tweak I made was that the resulting tree needs to have a distinct root node, meaning that abc
, efg
, opq
, etc. should all have a common parent.
tree_str = """
root
* abc
* 123
* 456(name='test', age=10)
* efg
* opq
* rst
"""
from bigtree import str_to_tree
tree = str_to_tree(tree_str, tree_prefix_list=["\* "]) # added \ as it is interpreted as regex
tree.show()
This will result in output,
root
├── abc
│ ├── 123
│ └── 456(name='test', age=10)
├── efg
├── opq
└── rst