Sync Markdown documentation to Confluence Cloud
Project description
md2confluence
A Python tool to sync Markdown documentation to Confluence Cloud.
Features
- Markdown to Confluence conversion - Headers, lists, tables, code blocks, info panels, task lists, and more
- Front-matter support - Per-document settings via YAML/JSON front-matter
- Emoji shortcodes -
:smile:→ 😄,:rocket:→ 🚀 - Subscript/superscript -
H~2~O→ H₂O,x^2^→ x² - Page labels - Set Confluence labels via front-matter tags
- Image handling - Automatically uploads local images as attachments
- Local output mode - Generate Confluence Storage Format files without API calls
- Config-driven - Define document mappings in a simple config file
- Dry-run mode - Preview changes before syncing
- Retry logic - Exponential backoff for transient failures
- Rate limiting - Avoid API throttling
Installation
# From PyPI (recommended)
pip install md2confluence
# For development
git clone <repository-url>
cd md2confluence
pip install -e .
Dependencies
- Python 3.9+
requestslibrary (installed automatically)
Quick Start
-
Create an API token (see Authentication below)
-
Set environment variables:
export CONFLUENCE_API_TOKEN="your-api-token" export CONFLUENCE_USER_EMAIL="your-email@example.com"
-
Create a config file (
.confluence-sync.conf):CONFLUENCE_BASE_URL="https://your-domain.atlassian.net/wiki" CONFLUENCE_SPACE_KEY="DOCS" CONFLUENCE_TECH_PARENT_ID="123456789" # Document mappings: "Title|path/to/file.md|parent_page_id" CONFLUENCE_DOC_README="README|README.md|${CONFLUENCE_TECH_PARENT_ID}"
-
Run the sync:
md2confluence
Usage
# Sync all configured documents
md2confluence
# Dry-run (preview without changes)
md2confluence --dry-run
# List configured documents
md2confluence --list
# Verify config and connectivity
md2confluence --verify
# Sync a single document
md2confluence --single "Page Title" path/to/doc.md parent_page_id
# Convert markdown to Confluence format (stdout)
echo "# Hello" | md2confluence --stdin
# Local output (generate .csf files without API calls)
md2confluence --local ./output
Authentication
Creating an API Token
- Go to Atlassian API Tokens
- Click Create API token
- Enter a label (e.g., "md2confluence") and click Create
- Copy the token immediately (you won't see it again)
Required Permissions
The user account associated with the API token needs:
-
Space permissions:
- View space
- Add pages
- Update pages
- Add attachments
-
Page permissions:
- View, Edit on target pages/parent pages
For organization-managed accounts, ensure the user has appropriate Confluence access in your Atlassian admin settings.
Auth Modes
| Mode | Variables Required | Use Case |
|---|---|---|
| Basic | CONFLUENCE_USER_EMAIL + CONFLUENCE_API_TOKEN |
Standard Atlassian Cloud |
| Bearer | CONFLUENCE_API_TOKEN only |
OAuth tokens, service accounts |
Auth mode is auto-detected based on whether CONFLUENCE_USER_EMAIL is set.
Configuration
See confluence-sync.conf.example for all available options.
Document Mappings
Define documents to sync using CONFLUENCE_DOC_* variables:
CONFLUENCE_DOC_MYPAGE="Page Title|path/to/file.md|parent_page_id"
Edge Case Handling
| Option | Values | Default |
|---|---|---|
CONFLUENCE_MISSING_FILE_BEHAVIOR |
skip, fail | skip |
CONFLUENCE_IMAGE_FAILURE_BEHAVIOR |
placeholder, skip, fail | placeholder |
CONFLUENCE_TITLE_SPECIAL_CHARS |
sanitize, encode, fail | sanitize |
Front-Matter
Documents can include YAML or JSON front-matter to override settings:
---
title: Custom Page Title
tags: [documentation, api, v2]
space: DOCS
parent_id: "123456789"
add_disclaimer: false
max_image_width: 600
synchronized: true
---
# Document content starts here
Supported Front-Matter Fields
| Field | Type | Description |
|---|---|---|
title |
string | Override page title |
tags / labels |
array | Confluence page labels |
space / space_key |
string | Target Confluence space |
parent_id / parent |
string | Parent page ID |
add_disclaimer |
boolean | Add auto-generated notice |
max_image_width |
integer | Image width constraint (px) |
image_failure_behavior |
string | Override error handling |
title_special_chars |
string | Override title sanitization |
synchronized / sync |
boolean | Set false to skip document |
Front-matter settings take precedence over config file and environment variables.
Markdown Support
- Headers (h1-h6)
- Bold, italic, strikethrough
- Subscript (
~text~) and superscript (^text^) - Ordered and unordered lists
- Nested lists
- Task lists (checkboxes)
- Tables
- Fenced code blocks with syntax highlighting
- Inline code
- Links (inline and reference-style)
- Images (uploaded as attachments)
- Blockquotes → Confluence panels (Note/Warning/Tip/Info)
- Horizontal rules
- Emoji shortcodes (
:smile:,:rocket:,:thumbsup:, etc.)
License
MIT
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 md2confluence-1.1.3.tar.gz.
File metadata
- Download URL: md2confluence-1.1.3.tar.gz
- Upload date:
- Size: 22.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fa18e35c060977cb22cdf85e028b7e160cee572d463741d1c09388aaea34910
|
|
| MD5 |
e534b5e9d686943873efda909e5bb804
|
|
| BLAKE2b-256 |
342dac73a5ec068024d3045d59bef18131784b16790af52b9f93543deb8f577b
|
File details
Details for the file md2confluence-1.1.3-py3-none-any.whl.
File metadata
- Download URL: md2confluence-1.1.3-py3-none-any.whl
- Upload date:
- Size: 23.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
daad7720f3a54ba68fc0cff82106a3295865d7aaef697065ae12299d7de8f008
|
|
| MD5 |
1e4a0cf61d25bfd801c42c29881e1dca
|
|
| BLAKE2b-256 |
f1790b3eb2fcbd738082263c2f0f6a5c9db43266e9c9627e7abd9ad9ffd2ccff
|