Skip to main content

Push locally edited markdown (exported with confluence-markdown-exporter) back to Confluence

Project description

confluence-markdown-importer

Push locally edited markdown back to Confluence. The counterpart of confluence-markdown-exporter (cme): you export a space to a git repository with cme, edit the markdown locally (for example with an AI coding agent, reviewed in a git branch), and then update the Confluence pages with cmi.

How it works

  • Shared configuration. cmi reads the same config file as cme (including CME_CONFIG_PATH and CME_* environment overrides). If cme is already set up, no extra credential setup is needed. To configure credentials, run cme config edit auth.confluence.
  • Shared page mapping. The exporter's confluence-lock.json maps local files to Confluence pages (page id, space, version). cmi never writes that file.
  • Own baseline state. cmi baseline records a sha256 hash of every tracked file in confluence-import-state.json next to the lockfile. cmi import pushes only files whose hash changed since the baseline. Commit this file to git together with confluence-lock.json so the baseline travels with the repository and every collaborator compares against the same clean state.
  • Conflict protection. Before updating a page, cmi compares the current Confluence version with the baseline version. If someone changed the page in Confluence since your export, the page is skipped and reported (override with --force).

Workflow

# 1. Export (cme) and snapshot the baseline (cmi)
cme space https://company.atlassian.net/wiki/spaces/KEY
cmi baseline
git add -A && git commit -m "docs: sync from Confluence"

# 2. Edit markdown locally, review in a branch

# 3. Preview and push
cmi import --dry-run
cmi import

# 4. Re-export to normalize local files to Confluence's canonical rendering,
#    then snapshot the new baseline
cme space https://company.atlassian.net/wiki/spaces/KEY
cmi baseline

Both commands take the export root directory as an optional argument (default: current directory).

Commands

Command Purpose
cmi baseline [DIR] Record the current files as the clean baseline. Run right after each export.
cmi import [DIR] --dry-run Show what would be pushed, including conversion warnings. Read-only.
cmi import [DIR] Update changed pages in Confluence.
cmi import [DIR] --force Also push pages that changed in Confluence since the baseline.

What gets converted

Exported markdown is converted back to Confluence storage format:

  • Headings, paragraphs, emphasis, lists, tables, blockquotes.
  • Fenced code blocks → Confluence code macro (with language).
  • GitHub alerts (> [!NOTE] etc.) → Confluence panel macros (exact inverse of the exporter's mapping).
  • Relative links to exported .md files → Confluence page links (resolved through the lockfile).
  • Attachment images → ri:attachment references (filenames resolved through the Confluence API).
  • <mark> / <font> spans → Confluence highlight / color spans.
  • The YAML frontmatter, breadcrumb line, and H1 title added by the exporter are stripped (honoring the corresponding cme export settings).

Every generated page body is validated as well-formed XML before it is sent.

Scope and limitations (v1)

  • Update existing pages only. New local files, locally deleted files, and files without a baseline are reported but not synced.
  • No title renames. The exported H1 can be a lossy rendering of the real page title, so cmi keeps the Confluence title and warns when the H1 differs.
  • Lossy for dynamic macros. The exporter renders macros (include, page properties reports, TOC, Jira links) into static markdown. Importing such a page replaces the live macro with that static rendering. Pages with plain text, tables, code, alerts, and links round-trip cleanly.
  • Unresolvable links degrade to text. Links to pages outside the exported space (not in the lockfile) and links to local attachment files are kept as plain text and reported as warnings.
  • Requires relative href exports. cmi import refuses to run when the cme config uses export.page_href or export.attachment_href other than relative (the default), because absolute and wiki-style links cannot be converted back.
  • No attachment upload and no comment sync.

Development

make setup    # create the environment (uv)
make test     # pytest
make lint     # ruff + mypy
make format   # autoformat
make build    # build wheel/sdist

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

confluence_markdown_importer-0.1.0.tar.gz (76.3 kB view details)

Uploaded Source

Built Distribution

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

confluence_markdown_importer-0.1.0-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file confluence_markdown_importer-0.1.0.tar.gz.

File metadata

File hashes

Hashes for confluence_markdown_importer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ecb8439850339652ef8e9fe17bb0f74113e523df413328d6b230ef12031044aa
MD5 5218a8ae76f51772d9f7fa99b563671c
BLAKE2b-256 2ca73ce3de494a738e626248dd385091de6f929ece0849e616adc31c1197f2d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for confluence_markdown_importer-0.1.0.tar.gz:

Publisher: publish.yml on stn1slv/confluence-markdown-importer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file confluence_markdown_importer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for confluence_markdown_importer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 822eef3c0846d6ab4f1823cff2d0d16e1b891913dcda9418209fd01b977e0532
MD5 4eb0765fbbb12b7921e5aaf8bb2eac1d
BLAKE2b-256 2b29b6c3d384519d6bfb46a762d076b936fc92f1bc95a636b671b60c76867f70

See more details on using hashes here.

Provenance

The following attestation bundles were made for confluence_markdown_importer-0.1.0-py3-none-any.whl:

Publisher: publish.yml on stn1slv/confluence-markdown-importer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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