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.0.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.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: marktree-1.3.0.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.0.tar.gz
Algorithm Hash digest
SHA256 29bb4b6ff4ea816c193035625a949cbac4a45433b1c0fa10dff8ad94e0590206
MD5 c7aaa693dc00594b86a44c89e5daaccd
BLAKE2b-256 c2c3fd7342cdb4df60d536ed27f8d45af919886bc5d825a9805fd0be2611baa4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: marktree-1.3.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6367d02dbf6dcb1e4cd5ce492e85df3378e6d657eb2d8a77103d95b4216ef24f
MD5 56f6133b6d7001593c8ec7cd4aba51a1
BLAKE2b-256 2d5cb8d2ef07493d84930bc36d80b9477c718bab4002481dbff4669c5424cfae

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