Convert headings in a Markdown file (.md) into a tree-like structure and output.
Project description
marktree
This command converts headings in a Markdown file (.md) into a tree-like structure and outputs it.
Table of Contents
Setup
Install via pip:
pip install marktree
Handling "Warning" on Windows
If you encounter a "WARNING: The script clipcount.exe is installed in 'path' which is not on PATH." when running the above command on Windows, please refer to the following article:
Reference: 【Python Windows】pip install でPATHが通らない時の解決方法 | ゆすノート
If you see "WARNING: Failed to write executable - trying to use .deleteme logic", please refer to the following article:
Reference: 【Windows】警告が出て「pip install」できない時の解決方法 | ゆすノート
Quick Usage
$ marktree [Options] [foo.md]
| Options | Description |
|---|---|
| marktree -h | Display the help screen. |
| marktree --help-jp | Display the help screen in Japanese. |
| marktree -L 3 | Determines the depth at which the tree is displayed (default: 6). |
| marktree -C | Outputs the Markdown text copied to the clipboard directly in tree format. |
| marktree -P | Outputs only the headings without tree formatting (plain view). |
| marktree -E | Specifies the file encoding (example: utf-8, cp932, shift_jis). Use this if you get a "Decode Failed" error (default: utf-8). |
Example
Prepare the following Markdown file foo.md:
# h1
This is an introduction paragraph under h1. It gives an overview of the section.
## h2
Here we discuss the first topic in detail, providing some context and background.
### h3
This subsection contains more specific details about the topic introduced above.
#### h4
Additional notes and clarifications are provided here to help understand the subtopic.
#### h4
Another set of points and examples relevant to this sub-subsection.
## h2
The second main point of this section is introduced here with supporting information.
## h2
This section explains another topic of equal importance, with examples and discussion.
### h3
A deeper dive into the details of the second topic, explaining key concepts.
#### h4
Specific use cases and examples are provided here to clarify the points above.
##### h5
Minor subpoints or notes that are relevant but not central to the discussion.
###### h6
Detailed footnotes, references, or additional tips can be added here for completeness.
### h3
Concluding remarks for this subsection, summarizing key takeaways.
# h1
Final section summarizing the overall content and providing closure.
- Regular output (default depth is 6):
$ marktree foo.md
├── h1
│ ├── h2
│ │ └── h3
│ │ ├── h4
│ │ └── h4
│ ├── h2
│ └── h2
│ ├── h3
│ │ └── h4
│ │ └── h5
│ │ └── h6
│ └── h3
└── h1
- Using
-L 3to limit depth:
$ marktree -L 3 foo.md
├── h1
│ ├── h2
│ │ └── h3
│ ├── h2
│ └── h2
│ ├── h3
│ └── h3
└── h1
- Using
-Cto read from clipboard directly (can combine with-L):
$ marktree -C -L 3
├── h1
│ ├── h2
│ │ └── h3
│ ├── h2
│ └── h2
│ ├── h3
│ └── h3
└── h1
- Using
-Pto output headings only:
$ marktree -C -P
# h1
## h2
### h3
#### h4
#### h4
## h2
## h2
### h3
#### h4
##### h5
###### h6
### h3
# h1
Usage
The marktree command outputs the file as a tree hierarchy based on the # headings in the Markdown file.
- The
-Loption specifies the output depth, similar to the originaltreecommand. Depth can be from 1 to 6; specifying more than that will result in an error (default: 6). - The
-Coption outputs Markdown text copied to the clipboard directly in tree format. This eliminates the need to copy the Markdown text to another file before outputting. - The
-Poption outputs headings in plain format without tree formatting. Use this if you only want the headings. - The
-Eoption allows you to specify the file encoding (examples:utf-8,cp932,shift_jis). Use this if you encounter a "Decode Failed" error (default:utf-8).
The order of options is flexible, including the Markdown file to be processed. If multiple files are provided (e.g., markdown foo.md hoge.md), only the last file will be converted and output.
Dependencies
Dev-diary
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file marktree-1.2.0.tar.gz.
File metadata
- Download URL: marktree-1.2.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.0 CPython/3.13.6 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5606204ea7fdc842be6512dc2651154dd940ed569231919886329fa9998e60d
|
|
| MD5 |
213cd0d84d4f3be3356d22443c65c823
|
|
| BLAKE2b-256 |
059e91b84eb898482a6d67903e2ee0670a457e4dfaf141a2939897882388067e
|
File details
Details for the file marktree-1.2.0-py3-none-any.whl.
File metadata
- Download URL: marktree-1.2.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.0 CPython/3.13.6 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8f058cc7e5b2f106b2cc1f00248dfff2806965a883715db390594ad5e0e3552
|
|
| MD5 |
657bda49f0ac5a89f4d14921587aba85
|
|
| BLAKE2b-256 |
31644a255fdaba86e64da12902465d19fc0c4a539294b2d8be08f3c1605e640e
|