Skip to main content

Convert headings in a Markdown file (.md) into a tree-like structure and output.

Project description

marktree

GitHub License PyPI - Version PyPI - Downloads

A CLI tool that displays the headings of a Markdown (.md) file as a tree structure.

Features

  • Display Markdown heading hierarchy as a tree
  • Limit the maximum heading level
  • Output headings as plain text
  • Read Markdown directly from the clipboard
  • Copy the generated result to the clipboard
  • Support UTF-8, CP932, Shift_JIS and other encodings

Japanese README

https://github.com/yusu79/marktree/blob/main/README.md

Table of Contents

Installation

pip install marktree

Quick Start

Markdown file:

# h1

## h2

### h3

## h2

# h1

Run:

marktree sample.md

Output:

├── h1
│  ├── h2
│  │  └── h3
│  └── h2
└── h1

Options

Command Description
marktree -h Show help
marktree -L 3 file.md Limit the maximum heading level
marktree -C Read Markdown from the clipboard
marktree -P file.md Output headings as plain text
marktree -E cp932 file.md Specify the file encoding
marktree --copy file.md Copy the result to the clipboard

Examples

Default Output

marktree sample.md
├── h1
│  ├── h2
│  │  └── h3
│  └── h2
└── h1

Limit the Heading Level

marktree -L 2 sample.md
├── h1
│  ├── h2
│  └── h2
└── h1

Read from the Clipboard

Reads the Markdown text currently stored in the clipboard.

marktree -C

You can combine it with the -L option.

marktree -C -L 3

Output Headings Only

marktree -P sample.md

Output:

# h1
## h2
### h3
## h2
# h1

Copy the Result to the Clipboard

Copies the generated tree to the clipboard instead of printing it to standard output.

marktree sample.md --copy

Specify the File Encoding

marktree -E cp932 sample.md

Supported examples:

  • utf-8
  • cp932
  • shift_jis

Option Details

-L

Displays headings up to the specified level. Valid values are 1–6 (default: 6).

-C

Uses the Markdown text currently stored in the clipboard as input.

This allows you to view the heading structure without saving the text to a file.

-P

Outputs only the headings without tree formatting.

-E

Specifies the file encoding, for example:

marktree -E cp932 sample.md

--copy

Copies the generated output to the clipboard instead of printing it to standard output.

Option Order

Options can be specified in any order.

marktree -L 3 sample.md
marktree sample.md -L 3

If multiple Markdown files are specified, only the last one is processed.

Windows Installation Warnings

If you see:

WARNING: The script xxx.exe is installed in '...' which is not on PATH.

See:

https://yusu79.com/python-path-issue/

If you see:

WARNING: Failed to write executable - trying to use .deleteme logic

See:

https://yusu79.com/pip-install-failure-fix/

Dependencies

Development Diary

https://yusu79.com/dev-marktree/

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

marktree-1.3.1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

marktree-1.3.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file marktree-1.3.1.tar.gz.

File metadata

  • Download URL: marktree-1.3.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0 CPython/3.14.5 Windows/11

File hashes

Hashes for marktree-1.3.1.tar.gz
Algorithm Hash digest
SHA256 bbd9769f66ab63328e1ad117acd298dfc9d19330460cd76ee78481d3514603cc
MD5 b5c61ae8da2840e056ddc02a673f0af6
BLAKE2b-256 f3c44ca3572c4f1a935b1499b4b3fb808594f80bdfa815e09b4a681251ce6dc9

See more details on using hashes here.

File details

Details for the file marktree-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: marktree-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0 CPython/3.14.5 Windows/11

File hashes

Hashes for marktree-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 41d0a1514e999912b1d303fd03f0fd77f738a9247a5e73648de936b477327788
MD5 8328aea17d37134034797cc441ec64ff
BLAKE2b-256 7c00b68c7862d96dc289971dd01ab7ef6686ff93317b9a932543ba9163966716

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page