A Python CLI package to sync markdown files to Notion and other platforms
Project description
mdsync
A Python CLI package to sync markdown files to Notion (and potentially other platforms in the future). One-way sync from markdown to platform with focus on simplicity and excellent markdown parsing.
Features
- One-way sync (markdown → platform)
- Dry-run mode to preview changes
- Command-line focused (simple args, no config files)
- Excellent markdown parsing with LaTeX support
- Preserve directory structure as nested pages
Installation
From PyPI
pip install mdsync
Quick Start
Prerequisites
- Create a Notion integration at https://www.notion.so/my-integrations
- Copy the integration token (starts with
ntn_) - Share a Notion page with your integration
- Copy the page ID or page URL from the Notion page
Usage
Sync a single markdown file:
mdsync notion --token ntn_... --parent PAGE_ID_or_PAGE_URL document.md
Sync an entire directory (preserves folder structure):
mdsync notion --token ntn_... --parent PAGE_ID_or_PAGE_URL docs/
Preview changes without syncing (dry-run):
mdsync notion --token ntn_... --parent PAGE_ID_or_PAGE_URL --dry-run docs/
Command-Line Options
Usage: mdsync notion [OPTIONS] PATH
Sync markdown files to Notion.
PATH can be a single markdown file or a directory containing markdown files.
Directories are synced recursively, preserving the folder structure.
Options:
--token TEXT Notion integration token [required]
--parent TEXT Parent page ID or page URL where files will
be synced [required]
--dry-run Preview changes without actually syncing
--page-icon Add random emoji icons to pages
--page-title [heading|filename]
How to determine page titles: 'heading'
(from first heading) or 'filename' (from
file/folder name)
--help Show this message and exit.
Supported Markdown Features
- Headings (H1, H2, H3, H4+ mapped to H3)
- Paragraphs with inline formatting:
- Bold
- Italic
StrikethroughInline code- Links
- Relative links between markdown files (auto-resolved to Notion pages)
- Code blocks with syntax highlighting
- Bulleted lists
- Numbered lists
- Nested lists
- Task lists (- [ ] and - [x])
- Blockquotes
- Tables with header detection
- Dividers/Horizontal rules
- LaTeX equations (
$...$inline,$$...$$block)- Note: Dollar signs are treated as math delimiters. To use
$for currency, escape it:\$4000
- Note: Dollar signs are treated as math delimiters. To use
- Line breaks
How It Works
- File Discovery: Finds all
.mdand.markdownfiles in the specified path - Parsing: Uses
mistletoeto parse markdown into an AST - Conversion: Transforms AST nodes to Notion block format
- Sync: Creates pages in Notion with proper hierarchy
- Link Resolution: Two-pass sync automatically resolves relative links between markdown files to Notion page URLs
- Output: Shows progress and summary with beautiful terminal output
Directory Structure Mapping
Folders are converted to nested pages in Notion:
docs/
├── Getting Started.md → Page: "Getting Started"
├── guides/ → Page: "Guides" (container)
│ ├── Installation.md → └─ Page: "Installation"
│ └── Configuration.md → └─ Page: "Configuration"
└── api/ → Page: "Api" (container)
├── Authentication.md → └─ Page: "Authentication"
└── Endpoints.md → └─ Page: "Endpoints"
Roadmap
Implemented Features
- LaTeX math equation support (inline and block)
- Relative link resolution between markdown files
- Task list support
- Strikethrough text support
- Nested lists
- Custom page icons (emoji)
- Configurable page title source (heading vs filename)
Future Features
- Additional platforms (Confluence, WordPress, Medium)
- Incremental sync / update detection
- Image upload support
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see the LICENSE file for details.
Acknowledgments
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 mdsync-0.1.4.tar.gz.
File metadata
- Download URL: mdsync-0.1.4.tar.gz
- Upload date:
- Size: 27.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bbbd0acb185d7eda8f51562ae7ca0fcf00d25600cd164e804d15c208a1a000b
|
|
| MD5 |
43102f435aa3208b99cbeac197bae9d1
|
|
| BLAKE2b-256 |
4a5c1df69564718400db046adc1e98ef401eccbe190356aada5f2dbee914b164
|
Provenance
The following attestation bundles were made for mdsync-0.1.4.tar.gz:
Publisher:
publish.yml on alasdairpan/mdsync
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mdsync-0.1.4.tar.gz -
Subject digest:
8bbbd0acb185d7eda8f51562ae7ca0fcf00d25600cd164e804d15c208a1a000b - Sigstore transparency entry: 1006120840
- Sigstore integration time:
-
Permalink:
alasdairpan/mdsync@675a6d871a5d8fbbe062d0f3b61ab5c0166ba399 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/alasdairpan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@675a6d871a5d8fbbe062d0f3b61ab5c0166ba399 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mdsync-0.1.4-py3-none-any.whl.
File metadata
- Download URL: mdsync-0.1.4-py3-none-any.whl
- Upload date:
- Size: 28.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ba0a3ce15ace5760fb448835be50846555a146ae1eea621465c5098f676dd99
|
|
| MD5 |
828dd156c00fe38392a6f27934d19403
|
|
| BLAKE2b-256 |
c05dcd1e50da1cb832b07330dd4d090a54eedb1f10f5ca3aa2de406ceb7a5323
|
Provenance
The following attestation bundles were made for mdsync-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on alasdairpan/mdsync
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mdsync-0.1.4-py3-none-any.whl -
Subject digest:
6ba0a3ce15ace5760fb448835be50846555a146ae1eea621465c5098f676dd99 - Sigstore transparency entry: 1006120855
- Sigstore integration time:
-
Permalink:
alasdairpan/mdsync@675a6d871a5d8fbbe062d0f3b61ab5c0166ba399 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/alasdairpan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@675a6d871a5d8fbbe062d0f3b61ab5c0166ba399 -
Trigger Event:
release
-
Statement type: