File: tree.md

package info (click to toggle)
markdown-exec 1.12.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 728 kB
  • sloc: python: 2,487; javascript: 120; makefile: 37; sh: 30
file content (126 lines) | stat: -rw-r--r-- 2,445 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Tree

Markdown Exec provides a `tree` formatter that can be used
to render file-system trees easily:

````md exec="1" source="tabbed-left" tabs="Markdown|Rendered"
```tree
root1
    file1
    dir1
        file
    dir2
        file1
        file2
    file2
    file3
root2
    file1
```
````

## Syntax highlight

By default, the language used for syntax highlight is `bash`.
It means you can add comments with `#`:

````md exec="1" source="tabbed-left" tabs="Markdown|Rendered"
```tree
root1            # comment 1
    file1
    dir1
        file
    dir2
        file1    # comment 2
        file2    # comment 3
    file2
    file3
root2
    file1
```
````

You can change the syntax highlight language with the `result` option:

````md exec="1" source="tabbed-left" tabs="Markdown|Rendered"
```tree result="javascript"
root1            // comment 1
    file1
    dir1
        file
    dir2
        file1    // comment 2
        file2    // comment 3
    file2
    file3
root2
    file1
```
````

## Leaf directories

You can force an entry to be displayed as a directory instead of a regular file
by appending a trailing slash to the name:

````md exec="1" source="tabbed-left" tabs="Markdown|Rendered"
```tree
root1
    dir1/
    dir2/
    dir3/
```
````

It is recommended to always append trailing slashes to directories anyway.

WARNING: **Limitation:**
Spaces in file names are not supported when searching for a trailing slash.

## Custom icons

Custom icons based on the file name and extension can be used in tree fences.
This feature requires that the [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) theme is used.
By default, if Material for MkDocs is used, custom icons will be rendered.
You can opt-out with `icons="basic"` to use the basic folder and file emojis,
or even remove all icons/emojis with `icons="none"`.

````md exec="1" source="tabbed-left" tabs="Markdown|Rendered"
```tree icons="none"
folder/
    file
    file.py
    file.rb
    file.js
```
````

````md exec="1" source="tabbed-left" tabs="Markdown|Rendered"
```tree icons="basic"
folder/
    file
    file.py
    file.rb
    file.rs
```
````

````md exec="1" source="tabbed-left" tabs="Markdown|Rendered"
```tree icons="material"
folder/
    file
    file.py
    file.rb
    file.rs
```
````

````md exec="1" source="tabbed-left" tabs="Markdown|Rendered"
```tree icons="auto"
folder/
    file
    file.py
    file.rb
    file.rs
```
````