Skip to main content

Bidirectional converter between GitHub Flavored Markdown and Atlassian Document Format

Project description

Marklas

CI PyPI Python License

Bidirectional converter between Markdown and Atlassian Document Format (ADF).


Why Marklas?

Confluence and Jira store documents in ADF — a rich JSON structure with panels, layouts, mentions, colored text, and more. Standard Markdown can only represent a subset of these features.

Marklas defines a union AST that covers both specs, then converts in both directions through it:

Markdown ⇄ Union AST ⇄ ADF

Nodes shared by both formats (paragraphs, headings, lists, tables, etc.) map directly. ADF-only nodes (panels, mentions, colored text, etc.) are embedded as invisible HTML comment annotations in the Markdown output, so the full structure survives a roundtrip:

ADF → Markdown (with annotations) → ADF   ✅ lossless

Without annotations, standard Markdown elements still convert to valid ADF — just without the ADF-specific extras:

Plain Markdown → ADF   ✅ works (standard elements only)

How Annotations Work

When ADF contains features that Markdown can't express natively (e.g., panels, mentions, colored text), Marklas wraps a readable Markdown fallback in HTML comment annotations:

<!-- adf:panel {"panelType": "info"} -->
This is an info panel — readable as plain Markdown.
<!-- /adf:panel -->

User <!-- adf:mention {"id": "abc123", "text": "@John"} -->`@John`<!-- /adf:mention --> approved this.

These annotations are invisible when rendered as Markdown (GitHub, editors, etc.), but Marklas can parse them back to reconstruct the original ADF structure exactly.

Installation

pip install marklas

Usage

from marklas import to_adf, to_md

Markdown → ADF

Any standard Markdown converts to valid ADF:

adf = to_adf("""
## Project Update

The release is **on track**. Key changes:

- Refactored auth module
- Fixed 3 critical bugs

| Component | Status |
| --------- | ------ |
| Backend   | Done   |
| Frontend  | WIP    |
""")

ADF → Markdown

ADF-only features (panels, mentions, colored text, etc.) are preserved as HTML comment annotations — invisible in rendered Markdown, but fully restorable:

md = to_md(adf_with_panel)
<!-- adf:panel {"panelType": "warning"} -->
Do **not** deploy on Fridays.
<!-- /adf:panel -->

To get clean Markdown without annotations, pass annotate=False. ADF-only attributes are stripped and only standard Markdown elements remain:

clean_md = to_md(adf_with_panel, annotate=False)
Do **not** deploy on Fridays.

Roundtrip

original_adf = fetch_confluence_page()     # complex ADF
markdown = to_md(original_adf)             # edit in any Markdown editor
restored_adf = to_adf(markdown)            # push back — structure preserved

Token Efficiency

Markdown is significantly more compact than ADF JSON — critical for LLM-based workflows where every token counts.

ADF JSON Markdown (annotated) Markdown (plain)
Tokens 243,217 76,541 41,744
Reduction 3.2x 5.8x

Measured on 7 real Confluence pages (pretty-printed JSON) using GPT-4o tokenizer (tiktoken).

Notes

  • Table cells: Non-paragraph content inside table cells (lists, code blocks, etc.) is converted to inline HTML (<ul>, <code>, <br>) to fit within GFM table syntax.
  • Markdown-only features: Raw HTML blocks/inlines and other Markdown-specific constructs that have no ADF equivalent are silently dropped during conversion.

Development

uv sync --extra dev
uv run pytest -v

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

marklas-0.4.6.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

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

marklas-0.4.6-py3-none-any.whl (30.9 kB view details)

Uploaded Python 3

File details

Details for the file marklas-0.4.6.tar.gz.

File metadata

  • Download URL: marklas-0.4.6.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for marklas-0.4.6.tar.gz
Algorithm Hash digest
SHA256 3874301074a213897ee5a0217d12f226eaf5c672c219046694a9843ce260677c
MD5 a7c7579839838078fe7ec253b5c0fa1e
BLAKE2b-256 7c7a49dff060e72234d6348d32656642eb7e1f37cf2a21690328d8ce5402b67a

See more details on using hashes here.

Provenance

The following attestation bundles were made for marklas-0.4.6.tar.gz:

Publisher: publish.yml on byExist/marklas

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

File details

Details for the file marklas-0.4.6-py3-none-any.whl.

File metadata

  • Download URL: marklas-0.4.6-py3-none-any.whl
  • Upload date:
  • Size: 30.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for marklas-0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d1e408527270cf5f70201d69418fa47fd2ef9cbe6cb6a0127077d195f79a152e
MD5 70d18807cbf0b9d2cff0bcd875782d8d
BLAKE2b-256 ba8f06fb77a74f2f7bc08239286ef760847a2207a0a2a45c8bcc020a5c823d9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for marklas-0.4.6-py3-none-any.whl:

Publisher: publish.yml on byExist/marklas

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