markdown-tree-parser
A powerful JavaScript library and CLI tool for parsing and manipulating markdown files as tree structures. Built on top of the battle-tested remark/unified ecosystem.
<div align="center" <!-- <img src="https://github.com/ksylvan/markdown-tree-parser/blob/main/logo.png?raw=true" alt="md-tree logo" width="200" height="200" -- <img src="./logo.png" alt="md-tree logo" width="200" height="200" </div
🚀 Features
- 🌳 Tree-based parsing - Treats markdown as manipulable Abstract Syntax Trees (AST)
- ✂️ Section extraction - Extract specific sections with automatic boundary detection
- 🔍 Powerful search - CSS-like selectors and custom search functions
- 📚 Batch processing - Process multiple sections at once
- 🛠️ CLI & Library - Use as a command-line tool or JavaScript library
- 📊 Document analysis - Get statistics and generate table of contents
- 🎯 TypeScript ready - Full type definitions included
📦 Installation
Global Installation (for CLI usage)
# Using npm
npm install -g @kayvan/markdown-tree-parser
# Using pnpm (may require approval for build scripts)
pnpm install -g @kayvan/markdown-tree-parser
pnpm approve-builds -g # If prompted
# Using yarn
yarn global add @kayvan/markdown-tree-parserLocal Installation (for library usage)
npm install @kayvan/markdown-tree-parser🔧 CLI Usage
After global installation, use the md-tree command:
List all headings
md-tree list README.md
md-tree list README.md --format jsonExtract specific sections
# Extract one section
md-tree extract README.md "Installation"
# Extract to a file
md-tree extract README.md "Installation" --output ./sections