Skip to main content

Sync Markdown documentation to Confluence Cloud

Project description

md2confluence

md2confluence

Python 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 git (recommended)
pip install git+ssh://git@bitbucket.org/bibliocommons/itops-md2confluence.git

# Or pin to a version
pip install git+ssh://git@bitbucket.org/bibliocommons/itops-md2confluence.git@v1.0.0

# For development
git clone git@bitbucket.org:bibliocommons/itops-md2confluence.git
cd itops-md2confluence
pip install -e .

Dependencies

  • Python 3.9+
  • requests library (installed automatically)

Quick Start

  1. Install:

    pip install git+ssh://git@bitbucket.org/bibliocommons/itops-md2confluence.git
    
  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.0.tar.gz (15.1 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.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: md2confluence-1.0.0.tar.gz
  • Upload date:
  • Size: 15.1 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.0.tar.gz
Algorithm Hash digest
SHA256 d041a9154c65919b7ff6e1aae9a82d90a5fc4de661f4d92ffba9faa796f16c53
MD5 0b1fe273f51720a0c4ee9552b08f9e1d
BLAKE2b-256 b214b097b55c683d72051de027f8632a5b0c6ca9c86a733e12063901c9e8c4d8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: md2confluence-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.8 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71bf6aecaf807747fc07d726a2064f8292d1fb784f54173c08e80b2f6d55f093
MD5 3432a17a0bc00ea20d5f3e81ff51d832
BLAKE2b-256 b64dc2b5bf5f6e7e5cc63337e4bad2f2218824bcd76392f680c9002e08cdee95

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