Skip to main content

Sync Markdown documentation to Confluence Cloud

Project description

md2confluence

md2confluence

Python PyPI Version License: MIT

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
  • Image handling - Automatically uploads local images as attachments
  • 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
  • Edge case handling - Configurable behavior for missing files, failed uploads, etc.

Installation

# From PyPI (recommended)
pip install md2confluence

# For development
git clone <repository-url>
cd md2confluence
pip install -e .

Dependencies

  • Python 3.9+
  • requests library (installed automatically)

Quick Start

  1. Install:

    pip install md2confluence
    
  2. Set environment variables:

    export CONFLUENCE_API_TOKEN="your-api-token"
    export CONFLUENCE_USER_EMAIL="your-email@example.com"  # For basic auth
    
  3. 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}"
    
  4. Run the sync:

    md2confluence
    

Usage

# Sync all configured documents
python md2confluence.py

# Dry-run (preview without changes)
python md2confluence.py --dry-run

# List configured documents
python md2confluence.py --list

# Verify config and connectivity
python md2confluence.py --verify

# Sync a single document
python md2confluence.py --single "Page Title" path/to/doc.md parent_page_id

# Convert markdown to Confluence format (stdin)
echo "# Hello" | python md2confluence.py --stdin

Configuration

See confluence-sync.conf.example for all available options.

Authentication

Supports two auth modes:

  • Basic auth: CONFLUENCE_USER_EMAIL + CONFLUENCE_API_TOKEN
  • Bearer auth: CONFLUENCE_API_TOKEN only (OAuth tokens)

Auto-detected based on whether CONFLUENCE_USER_EMAIL is set.

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

Markdown Support

  • Headers (h1-h6)
  • Bold, italic, strikethrough
  • 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

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

md2confluence-1.0.1.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

md2confluence-1.0.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file md2confluence-1.0.1.tar.gz.

File metadata

  • Download URL: md2confluence-1.0.1.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for md2confluence-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0fc941ea9fa32d1c44bc8db370510026bc7236917f948e506620888f59dc5383
MD5 99972cf8fde2e2bebe9a323ad567b504
BLAKE2b-256 169ced28ac354bd3b50e06df2e1e34f84f1c258ee4c6b0edb54ea73c5bd9e3bf

See more details on using hashes here.

File details

Details for the file md2confluence-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: md2confluence-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for md2confluence-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 544334a0f8b3f416e82e3f36d67d593406be1b22179104a341a310c609fefd1a
MD5 0419ee1bf6eb9431e6a79a7b3a2d0c6a
BLAKE2b-256 23b9d62ae261851df1dc82140d31f9ecf9d6d20ca6cb694c10e8070eca4c213b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page