Feature Request - Markdown List Format Support
junxnone opened this issue · comments
bigtree/bigtree/tree/export.py
Lines 21 to 29 in a9e5147
Markdown List
- 1
- 1.1
- 1.1.1
- 1.1.1.1
- 1.1.1
- 1.2
- 1.2.1
- 1.1
- 2
- 2.1
- 3
- 4
This seems to be printing bullet points depending on the depth of the node - all bullet points seems to be shaded-square and only the first two depth are shaded and unshaded circles respectively.
You can use custom style and use shaded-square bullet and do an if-else to replace the bullet points of the first two depth.
Below is the sample code that I tried
from bigtree import list_to_tree, yield_tree
# Construct tree
path_list = [
"root/1/1.1/1.1.1/1.1.1.1",
"root/1/1.2/1.2.1",
"root/2/2.1",
"root/3",
"root/4",
]
root = list_to_tree(path_list)
# Print tree
for branch, stem, node in yield_tree(root, style="custom", custom_style=(" ", " \u25AA ", " \u25AA ")):
if node.depth == 2:
stem = stem.replace("\u25AA", "\u2022")
elif node.depth == 3:
stem = stem.replace("\u25AA", "\u25E6")
print(f"{branch}{stem}{node.node_name}")
This results in the output
root
• 1
◦ 1.1
▪ 1.1.1
▪ 1.1.1.1
◦ 1.2
▪ 1.2.1
• 2
◦ 2.1
• 3
• 4
Thanks a lot for reply and the example code.
it works for me.