A Python package for integrating Markdown files with cloud object storage
Project description
md-corpus
A Python package for integrating Markdown files with cloud object storage. It helps you:
- Format Markdown files using consistent style
- Upload images to cloud storage (Aliyun OSS, AWS S3)
- Convert local image links to cloud storage URLs
Requirements
- Python >= 3.10
- Dependencies:
- boto3 (AWS S3 support)
- oss2 (Aliyun OSS support)
- click (CLI tool)
- markdown (Markdown processing)
- mdformat (Markdown formatting)
Installation
# Install from PyPI
pip install md-corpus
# Or install from source
git clone https://github.com/wangyiyang/md-corpus.git
cd md-corpus
pip install -e .
Features
1. Format Markdown Files
Format your Markdown files using consistent style:
# Format a single file
md-corpus format path/to/file.md
# Format all Markdown files in a directory (including subdirectories)
md-corpus format path/to/directory
The formatter will:
- Use
-for list items (mdformat default) - Ensure consistent heading styles
- Maintain code blocks and their language specifications
- Preserve blank lines for readability
2. Convert Image Links
Convert local image links to cloud storage URLs:
# Convert a single file
md-corpus convert path/to/file.md --provider aliyun --bucket your-bucket
# Convert all Markdown files in a directory
md-corpus convert path/to/directory --provider aliyun --bucket your-bucket
When converting files, md-corpus will:
- Format the Markdown content for consistent style
- Upload referenced images to cloud storage
- Update image links to use cloud storage URLs
Cloud Storage Providers
Aliyun OSS
# Using command line arguments
md-corpus convert file.md \
--provider aliyun \
--bucket your-bucket \
--access-key your-access-key \
--secret-key your-secret-key \
--endpoint https://oss-cn-beijing.aliyuncs.com
# Using environment variables
export ALI_OSS_ACCESS_KEY_ID=your-access-key
export ALI_OSS_ACCESS_KEY_SECRET=your-secret-key
export ALI_OSS_BUCKET=your-bucket
export ALI_OSS_ENDPOINT=https://oss-cn-beijing.aliyuncs.com
md-corpus convert file.md --provider aliyun
AWS S3
# Using command line arguments
md-corpus convert file.md \
--provider aws \
--bucket your-bucket \
--access-key your-access-key \
--secret-key your-secret-key \
--region us-east-1
# Using environment variables
export AWS_ACCESS_KEY_ID=your-access-key
export AWS_SECRET_ACCESS_KEY=your-secret-key
export AWS_BUCKET=your-bucket
export AWS_REGION=us-east-1
md-corpus convert file.md --provider aws
Development
- Clone the repository:
git clone https://github.com/wangyiyang/md-corpus.git
cd md-corpus
- Create a conda environment:
conda create -n md-corpus python=3.10
conda activate md-corpus
- Install development dependencies:
pip install -e .
- Run tests:
# Run all tests
pytest tests/
# Run specific test file
pytest tests/test_core.py
# Run with verbose output
pytest tests/ -v
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT License
Project details
Release history Release notifications | RSS feed
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 md_corpus-0.1.1.tar.gz.
File metadata
- Download URL: md_corpus-0.1.1.tar.gz
- Upload date:
- Size: 362.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c73779dffae979fc0a6aaf0e8a101f1663b9c1e40cb894bae8a4e87df655435
|
|
| MD5 |
f01ee416191a5b8c0d4104e5f01c8fa9
|
|
| BLAKE2b-256 |
0c9e8b552525f6cb73138a67fc2b758a913dddda3f7c54d8cbf23c2eaa943a07
|
File details
Details for the file md_corpus-0.1.1-py3-none-any.whl.
File metadata
- Download URL: md_corpus-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a101674762834c0aa0f3ad0d89113619d57fbff1b36505d11757fa4cd792b62f
|
|
| MD5 |
c16d1538b50e64d4ed4f7658c8ffe7af
|
|
| BLAKE2b-256 |
75e28a11a7b122f279f1e73a64d773832cb4df955357d883b22024919e166f87
|