XMind Converter is a Python library for converting XMind files to and from CSV (triples), Markdown, HTML, JSON.
Project description
XMind Converter
XMind Converter is a Python library for converting XMind files to and from CSV (triples), Markdown, HTML, JSON.
Features
- Supports XMind file parsing
- Supports conversion to CSV, Markdown, HTML, JSON formats
- Supports conversion from CSV, Markdown, HTML, JSON formats back to XMind
- Provides command line tool
- Supports Python 3.7+
Supported File Formats
CSV Format
CSV files must follow a specific structure with a header row and parent-child relationships:
parent,child,relationship
Root,Child1,contains
Child1,Grandchild1,contains
Root,Child2,contains
Markdown Format
Markdown files use heading levels (#, ##, ###, etc.) to represent hierarchy:
# Root
## Child1
### Grandchild1
## Child2
HTML Format
HTML files use heading tags (h1, h2, h3, etc.) to represent hierarchy:
<h1>Root</h1>
<h2>Child1</h2>
<h3>Grandchild1</h3>
<h2>Child2</h2>
JSON Format
JSON files must contain a specific structure with name and root_node fields:
{
"name": "MindMap Name",
"root_node": {
"title": "Root",
"id": "root-id",
"children": [
{
"title": "Child1",
"id": "child1-id",
"children": [
{
"title": "Grandchild1",
"id": "grandchild1-id",
"children": []
}
]
}
]
}
}
Note: Only files following these specific formats can be successfully parsed and converted.
Installation
Using uv (Recommended)
# Install uv if you haven't already
# https://docs.astral.sh/uv/getting-started/installation/
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install xmind-converter
uv add xmind-converter
Using pip
pip install xmind-converter
Install from source
# Clone repository
git clone https://github.com/DOcrazyG/xmind-converter.git
cd xmind-converter
# Install using uv (recommended)
uv add .
# Or using pip
pip install -e .
Basic Usage
Python API
from xmind_converter import CoreConverter
# Create converter instance
converter = CoreConverter()
# Load XMind file
mindmap = converter.load_from('example.xmind')
# Convert to CSV
converter.convert_to(mindmap, 'csv', 'output.csv')
# Convert to Markdown
converter.convert_to(mindmap, 'md', 'output.md')
# Convert to HTML
converter.convert_to(mindmap, 'html', 'output.html')
# Convert to JSON
converter.convert_to(mindmap, 'json', 'output.json')
# Convert from CSV to XMind
converter.convert('input.csv', 'output.xmind')
# Convert from Markdown to XMind
converter.convert('input.md', 'output.xmind')
# Convert from HTML to XMind
converter.convert('input.html', 'output.xmind')
# Convert from JSON to XMind
converter.convert('input.json', 'output.xmind')
Command Line Tool
# Convert XMind file to CSV
xmind-converter convert example.xmind output.csv
# Convert XMind file to Markdown
xmind-converter convert example.xmind output.md
# Convert XMind file to HTML
xmind-converter convert example.xmind output.html
# Convert XMind file to JSON
xmind-converter convert example.xmind output.json
# Convert CSV to XMind
xmind-converter convert input.csv output.xmind
# Convert Markdown to XMind
xmind-converter convert input.md output.xmind
# Convert HTML to XMind
xmind-converter convert input.html output.xmind
# Convert JSON to XMind
xmind-converter convert input.json output.xmind
# Convert between any formats
xmind-converter convert input.csv output.md
# View version information
xmind-converter info
Project Structure
xmind_converter/
├── __init__.py # Package initialization
├── core.py # Core converter class
├── models.py # Data models (MindMap, MindNode)
├── parsers/ # Parser modules
│ ├── __init__.py
│ ├── base_parser.py # Base parser class
│ ├── xmind_parser.py # XMind file parser
│ ├── csv_parser.py # CSV parser
│ ├── md_parser.py # Markdown parser
│ ├── html_parser.py # HTML parser
│ └── json_parser.py # JSON parser
├── converters/ # Converter modules
│ ├── __init__.py
│ ├── base_converter.py # Base converter class
│ ├── csv_converter.py # CSV converter
│ ├── md_converter.py # Markdown converter
│ ├── html_converter.py # HTML converter
│ ├── json_converter.py # JSON converter
│ └── xmind_converter.py # XMind converter
├── exceptions.py # Exception definitions
└── cli.py # Command line tool
tests/ # Test code
docs/ # Documentation
Dependencies
- Python 3.7+
- click >= 8.0.0
Development Dependencies
- pytest >= 6.0.0 (testing)
- black >= 21.0.0 (code formatting)
- flake8 >= 4.0.0 (linting)
Testing
# Run tests using uv (recommended)
uv run pytest tests/
# Run tests with coverage
uv run pytest tests/ --cov=xmind_converter
# Or using pip
pytest tests/
pytest tests/ --cov=xmind_converter
Development
# Install development dependencies using uv
uv add --dev .
# Or using pip
pip install -e ".[dev]"
# Format code with black
uv run black xmind_converter/ tests/
# Or using pip
black xmind_converter/ tests/
# Lint code with flake8
uv run flake8 xmind_converter/ tests/
# Or using pip
flake8 xmind_converter/ tests/
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details
Contact
- Author: DOcrazyG
- Email: lyuuhao@gmail.com
- Project Link: https://github.com/DOcrazyG/xmind-converter.git
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 xmind_converter-0.1.1.tar.gz.
File metadata
- Download URL: xmind_converter-0.1.1.tar.gz
- Upload date:
- Size: 20.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"20.04","id":"focal","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6a1ad1051991e13718e994a96023b9fb03710be7991ce7585974fcf5da09390
|
|
| MD5 |
e95a1d14bc903ff9a819b0b7655d45cf
|
|
| BLAKE2b-256 |
1b36926d9650fbfb2138ae13727c759d221849bb949880931a7d092ad9527ee7
|
File details
Details for the file xmind_converter-0.1.1-py3-none-any.whl.
File metadata
- Download URL: xmind_converter-0.1.1-py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"20.04","id":"focal","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6336b0418f3fe9d5f2c8fed168ffdcb3d2dce11a28c1e20c27445126b7240c1
|
|
| MD5 |
c8b8fd066d1e9be4282e1bccf60d0d53
|
|
| BLAKE2b-256 |
97221024764568e22f70d8bf1af30f7255b042ff20a3c93144a754cc1755cc9d
|