c2md


Namec2md JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
SummaryCLI tool to convert Context7 llms.txt format to locally organized markdown documentation
upload_time2025-07-11 17:41:12
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords cli context7 converter documentation markdown
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Context7 to Markdown (`c2md`)

A blazing fast CLI tool that converts Context7 URLs & llms.txt files to organized markdown documentation with automatic directory structure, multi-language parsing support, and table of contents generation. Supports both local files and direct URLs from Context7.com.

Install with pip
```bash
pip install c2md
```
Install with uv
```bash
uv pip install c2md
```
```bash
uvx c2md
```
## Features

#### **βš“ Convert Context7 to Markdown**

Transform Context7 links or llms.txt files into clean, organized markdown documentation.

#### **🧠 Smart Organization**

Automatically organizes markdown files into logical directory structures based on source URLs.

#### **πŸ—¨οΈ Multi-Language Support**

Consolidates multi-language sections into a single document.

#### **πŸ“œ Table of Contents** 

Generates comprehensive index files to provide context to your agent.

#### **πŸ—ΊοΈ URL Mapping** 

Intelligently maps source URLs to appropriate file paths and names

#### **❌ Error Handling**
Robust error handling with detailed feedback for troubleshooting

## Why `c2md`? πŸ€”

MCP is clunky, slow, adds additional prompt context, and time consuming. 

With `c2md`, you can pass a specific section of a technology's documentation to an agent. Instead of fairly unreliable natural language search with the Context7 MCP server, you can just attach the `@/path/to/000-index.md` to your agent. 

Depending on the number of locally available documentation sections/files, this can save tokens/context. For example, the Neon docs have around 240 sections (520,000 tokens), with the total 000-index.md costing around 4,000 tokens; alternatively, calls to the Context7 MCP can cost anywhere from 8,000 to 20,000 tokens.  

## Installation

#### Using pip

```bash
pip install c2md
```

#### Using uv

```bash
uv pip install c2md
```
or
```bash
uvx c2md
```

## πŸ“‹ Requirements

- Python 3.8 or higher
- No external dependencies required unless developing

## πŸ› οΈ Usage

After installation, use the `c2md` command:

### Basic Usage

```bash
# From local file - output defaults to ./output/
c2md /path/to/llms.txt

# From Context7 URL (must include tokens parameter)
c2md https://context7.com/context7/neon/llms.txt?tokens=519821
```

### Advanced Usage

```bash
# Specify output directory, 001-index.md (ToC) generated in output root
c2md /path/to/llms.txt -d /path/to/output

# From Context7 URL with output directory
c2md https://context7.com/context7/neon/llms.txt?tokens=519821 -d .docs/neon

# Disable ToC generation
c2md /path/to/llms.txt --no-tree

# Full example with all options, no ToC/tree
c2md https://context7.com/context7/supabase/llms.txt?tokens=1000000 -d /path/to/output --no-tree
```

### Command Line Options

- `input_file`: Path to the Context7 format input file or Context7 URL (required)
- `-d, --directory`: Output directory (default: current directory)
- `-T, --tree`: Generate table of contents index (default: enabled)
- `--no-tree`: Disable table of contents generation
- `-h, --help`: Show help message and exit

<details>
    <summary>
    <strong>Developing locally & contributing</strong>
    </summary>

### Contributing 🀝

Contributions are welcome! Please feel free to submit a PR if you would like to contribute or have an issue.

### Development Installation

```bash
# Clone the repository
git clone https://github.com/crisp-sh/context7-to-markdown.git
cd context7-to-markdown

# Install in development mode
pip install -e .
```

### Output Structure

The tool creates an organized directory structure:

```
output/
β”œβ”€β”€ 001-index.md                    # Table of contents (if enabled)
β”œβ”€β”€ domain1.com/
β”‚   β”œβ”€β”€ section1/
β”‚   β”‚   β”œβ”€β”€ 001-page1.md
β”‚   β”‚   └── 002-page2.md
β”‚   └── section2/
β”‚       └── 001-page3.md
└── domain2.com/
    └── docs/
        └── 001-guide.md
```

### Context7 Format

The tool processes Context7 format files, which should contain entries with:
- **SOURCE**: URL or source identifier
- **CONTENT**: The actual content to be converted
- **TITLE**: Optional title for the content
- **LANGUAGE**: Denotes a multi-language document

### Architecture

The tool consists of several modular components:

- **Parser**: Processes Context7 format files
- **URL Mapper**: Maps source URLs to file paths
- **File Organizer**: Organizes content into directory structures
- **Markdown Writer**: Generates clean markdown files
- **Index Generator**: Creates table of contents

### Testing

Run the test suite using Hatch:

```bash
# Run tests
hatch run test

# Run tests with coverage
hatch run test-cov

# Run specific test file
hatch run test tests/test_specific.py
```

### Legacy Testing

```bash
# Install development dependencies
pip install -e ".[dev]"

# Run tests
python -m unittest discover tests

# Run tests with coverage
python -m unittest discover tests
```

### Releasing

This project uses automated versioned releases with [Hatch](https://hatch.pypa.io/) for version management.

#### Quick Release

```bash
# Create a patch release (0.1.0 β†’ 0.1.1)
hatch run release patch

# Create a minor release (0.1.0 β†’ 0.2.0)
hatch run release minor

# Create a major release (0.1.0 β†’ 1.0.0)
hatch run release major
```

#### Development Setup

```bash
# Clone the repository
git clone https://github.com/crisp-sh/context7-to-markdown.git
cd context7-to-markdown

# Create a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install
pip install -e .
```

#### Running Tests

```bash
# Run all tests with Hatch
hatch run test

# Run specific test file
hatch run test tests/test_specific.py

# Run tests with coverage
hatch run test-cov
```
</details>

## Bug Reports

If you encounter any issues, please report them on the [GitHub Issues](https://github.com/crisp-sh/context7-to-markdown/issues) page.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "c2md",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "cli, context7, converter, documentation, markdown",
    "author": null,
    "author_email": "crisp-sh <s@crisp.sh>",
    "download_url": "https://files.pythonhosted.org/packages/f4/f8/f29eeb4ec325415433a322b3ba32a0bb32a47da6e97bea7aeb36f652bb45/c2md-1.0.2.tar.gz",
    "platform": null,
    "description": "# Context7 to Markdown (`c2md`)\n\nA blazing fast CLI tool that converts Context7 URLs & llms.txt files to organized markdown documentation with automatic directory structure, multi-language parsing support, and table of contents generation. Supports both local files and direct URLs from Context7.com.\n\nInstall with pip\n```bash\npip install c2md\n```\nInstall with uv\n```bash\nuv pip install c2md\n```\n```bash\nuvx c2md\n```\n## Features\n\n#### **\u2693 Convert Context7 to Markdown**\n\nTransform Context7 links or llms.txt files into clean, organized markdown documentation.\n\n#### **\ud83e\udde0 Smart Organization**\n\nAutomatically organizes markdown files into logical directory structures based on source URLs.\n\n#### **\ud83d\udde8\ufe0f Multi-Language Support**\n\nConsolidates multi-language sections into a single document.\n\n#### **\ud83d\udcdc Table of Contents** \n\nGenerates comprehensive index files to provide context to your agent.\n\n#### **\ud83d\uddfa\ufe0f URL Mapping** \n\nIntelligently maps source URLs to appropriate file paths and names\n\n#### **\u274c Error Handling**\nRobust error handling with detailed feedback for troubleshooting\n\n## Why `c2md`? \ud83e\udd14\n\nMCP is clunky, slow, adds additional prompt context, and time consuming. \n\nWith `c2md`, you can pass a specific section of a technology's documentation to an agent. Instead of fairly unreliable natural language search with the Context7 MCP server, you can just attach the `@/path/to/000-index.md` to your agent. \n\nDepending on the number of locally available documentation sections/files, this can save tokens/context. For example, the Neon docs have around 240 sections (520,000 tokens), with the total 000-index.md costing around 4,000 tokens; alternatively, calls to the Context7 MCP can cost anywhere from 8,000 to 20,000 tokens.  \n\n## Installation\n\n#### Using pip\n\n```bash\npip install c2md\n```\n\n#### Using uv\n\n```bash\nuv pip install c2md\n```\nor\n```bash\nuvx c2md\n```\n\n## \ud83d\udccb Requirements\n\n- Python 3.8 or higher\n- No external dependencies required unless developing\n\n## \ud83d\udee0\ufe0f Usage\n\nAfter installation, use the `c2md` command:\n\n### Basic Usage\n\n```bash\n# From local file - output defaults to ./output/\nc2md /path/to/llms.txt\n\n# From Context7 URL (must include tokens parameter)\nc2md https://context7.com/context7/neon/llms.txt?tokens=519821\n```\n\n### Advanced Usage\n\n```bash\n# Specify output directory, 001-index.md (ToC) generated in output root\nc2md /path/to/llms.txt -d /path/to/output\n\n# From Context7 URL with output directory\nc2md https://context7.com/context7/neon/llms.txt?tokens=519821 -d .docs/neon\n\n# Disable ToC generation\nc2md /path/to/llms.txt --no-tree\n\n# Full example with all options, no ToC/tree\nc2md https://context7.com/context7/supabase/llms.txt?tokens=1000000 -d /path/to/output --no-tree\n```\n\n### Command Line Options\n\n- `input_file`: Path to the Context7 format input file or Context7 URL (required)\n- `-d, --directory`: Output directory (default: current directory)\n- `-T, --tree`: Generate table of contents index (default: enabled)\n- `--no-tree`: Disable table of contents generation\n- `-h, --help`: Show help message and exit\n\n<details>\n    <summary>\n    <strong>Developing locally & contributing</strong>\n    </summary>\n\n### Contributing \ud83e\udd1d\n\nContributions are welcome! Please feel free to submit a PR if you would like to contribute or have an issue.\n\n### Development Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/crisp-sh/context7-to-markdown.git\ncd context7-to-markdown\n\n# Install in development mode\npip install -e .\n```\n\n### Output Structure\n\nThe tool creates an organized directory structure:\n\n```\noutput/\n\u251c\u2500\u2500 001-index.md                    # Table of contents (if enabled)\n\u251c\u2500\u2500 domain1.com/\n\u2502   \u251c\u2500\u2500 section1/\n\u2502   \u2502   \u251c\u2500\u2500 001-page1.md\n\u2502   \u2502   \u2514\u2500\u2500 002-page2.md\n\u2502   \u2514\u2500\u2500 section2/\n\u2502       \u2514\u2500\u2500 001-page3.md\n\u2514\u2500\u2500 domain2.com/\n    \u2514\u2500\u2500 docs/\n        \u2514\u2500\u2500 001-guide.md\n```\n\n### Context7 Format\n\nThe tool processes Context7 format files, which should contain entries with:\n- **SOURCE**: URL or source identifier\n- **CONTENT**: The actual content to be converted\n- **TITLE**: Optional title for the content\n- **LANGUAGE**: Denotes a multi-language document\n\n### Architecture\n\nThe tool consists of several modular components:\n\n- **Parser**: Processes Context7 format files\n- **URL Mapper**: Maps source URLs to file paths\n- **File Organizer**: Organizes content into directory structures\n- **Markdown Writer**: Generates clean markdown files\n- **Index Generator**: Creates table of contents\n\n### Testing\n\nRun the test suite using Hatch:\n\n```bash\n# Run tests\nhatch run test\n\n# Run tests with coverage\nhatch run test-cov\n\n# Run specific test file\nhatch run test tests/test_specific.py\n```\n\n### Legacy Testing\n\n```bash\n# Install development dependencies\npip install -e \".[dev]\"\n\n# Run tests\npython -m unittest discover tests\n\n# Run tests with coverage\npython -m unittest discover tests\n```\n\n### Releasing\n\nThis project uses automated versioned releases with [Hatch](https://hatch.pypa.io/) for version management.\n\n#### Quick Release\n\n```bash\n# Create a patch release (0.1.0 \u2192 0.1.1)\nhatch run release patch\n\n# Create a minor release (0.1.0 \u2192 0.2.0)\nhatch run release minor\n\n# Create a major release (0.1.0 \u2192 1.0.0)\nhatch run release major\n```\n\n#### Development Setup\n\n```bash\n# Clone the repository\ngit clone https://github.com/crisp-sh/context7-to-markdown.git\ncd context7-to-markdown\n\n# Create a virtual environment\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n\n# Install\npip install -e .\n```\n\n#### Running Tests\n\n```bash\n# Run all tests with Hatch\nhatch run test\n\n# Run specific test file\nhatch run test tests/test_specific.py\n\n# Run tests with coverage\nhatch run test-cov\n```\n</details>\n\n## Bug Reports\n\nIf you encounter any issues, please report them on the [GitHub Issues](https://github.com/crisp-sh/context7-to-markdown/issues) page.",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "CLI tool to convert Context7 llms.txt format to locally organized markdown documentation",
    "version": "1.0.2",
    "project_urls": {
        "Bug Reports": "https://github.com/crisp-sh/context7-to-markdown/issues",
        "Homepage": "https://github.com/crisp-sh/context7-to-markdown",
        "Source": "https://github.com/crisp-sh/context7-to-markdown"
    },
    "split_keywords": [
        "cli",
        " context7",
        " converter",
        " documentation",
        " markdown"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "dbd1429adda9a0c2ebb67156746fbfeebc1fd16c92f849d733bbb58daebc2021",
                "md5": "04ae08d51282132c18d4d81e916c1c98",
                "sha256": "73950878a0c2a55dbe872ff7a1274b3144d87a0c9175b63b7f605d8b17d30a17"
            },
            "downloads": -1,
            "filename": "c2md-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "04ae08d51282132c18d4d81e916c1c98",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 24175,
            "upload_time": "2025-07-11T17:41:11",
            "upload_time_iso_8601": "2025-07-11T17:41:11.513106Z",
            "url": "https://files.pythonhosted.org/packages/db/d1/429adda9a0c2ebb67156746fbfeebc1fd16c92f849d733bbb58daebc2021/c2md-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f4f8f29eeb4ec325415433a322b3ba32a0bb32a47da6e97bea7aeb36f652bb45",
                "md5": "9d457e7f32d01dab1dd77dcb1bd94643",
                "sha256": "55016c0a1a24773df7960cd5c7abbd246cf8f66e210f1b4da973e2aa5b9053e2"
            },
            "downloads": -1,
            "filename": "c2md-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "9d457e7f32d01dab1dd77dcb1bd94643",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 20195,
            "upload_time": "2025-07-11T17:41:12",
            "upload_time_iso_8601": "2025-07-11T17:41:12.546732Z",
            "url": "https://files.pythonhosted.org/packages/f4/f8/f29eeb4ec325415433a322b3ba32a0bb32a47da6e97bea7aeb36f652bb45/c2md-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-11 17:41:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "crisp-sh",
    "github_project": "context7-to-markdown",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "c2md"
}
        
Elapsed time: 1.11924s