Skip to main content

Convert Markdown to Atlassian Document Format (ADF)

Project description

marklassian-py

A lightweight Python library that converts Markdown to the Atlassian Document Format (ADF). Built for easy integration with Atlassian products like Jira and Confluence.

This is a Python port of the excellent marklassian JavaScript library by @jamsinclair.

Features

  • Convert Markdown to ADF with a single function call
  • Support for common Markdown syntax including GFM task lists
  • Minimal dependencies (only mistune)
  • Full type hints for IDE support
  • Python 3.10+

Installation

pip install marklassian

Or with uv:

uv add marklassian

Usage

from marklassian import markdown_to_adf

markdown = "# Hello World\n\nThis is **bold** and *italic* text."
adf = markdown_to_adf(markdown)

The result is a dictionary that can be serialized to JSON:

import json
print(json.dumps(adf, indent=2))

Supported Markdown Features

  • Headings (H1-H6)
  • Paragraphs and line breaks
  • Emphasis (bold, italic, strikethrough)
  • Links and images
  • Inline code and code blocks with language support
  • Ordered and unordered lists with nesting
  • Blockquotes
  • Horizontal rules
  • Tables
  • Task lists (GitHub Flavored Markdown)

API Reference

markdown_to_adf(markdown: str) -> AdfDocument

Converts a Markdown string to an ADF document object.

Types

class AdfMark(TypedDict, total=False):
    type: Required[str]
    attrs: dict[str, Any]

class AdfNode(TypedDict, total=False):
    type: Required[str]
    attrs: dict[str, Any]
    content: list[AdfNode]
    marks: list[AdfMark]
    text: str

class AdfDocument(TypedDict):
    version: Literal[1]
    type: Literal["doc"]
    content: list[AdfNode]

Caveats

This library aims to provide a lightweight and mostly accurate conversion from Markdown to ADF.

For complex Markdown documents or strict ADF conformance requirements, consider using the official Atlassian libraries. Note that those are heavier dependencies.

References

Credits

This library is a Python port of marklassian by Jamie Sinclair. All credit for the original implementation and conversion logic goes to them.

License

MIT - see LICENSE for details.

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

marklassian-0.1.0.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

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

marklassian-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: marklassian-0.1.0.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for marklassian-0.1.0.tar.gz
Algorithm Hash digest
SHA256 270b595ceddb6748c1e2ce4e3b02ddd5468bd0eab6aff2a12711c5b68335231b
MD5 6daee8ef7f92263ded9aca46b1406f41
BLAKE2b-256 c9f565c44c8a37196612d7a878a87729fa10683a5d41646a1518b3ad64523308

See more details on using hashes here.

File details

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

File metadata

  • Download URL: marklassian-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for marklassian-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 775ab546d0843457453496748948972b9465ca3be3d401425ce260bb358b042f
MD5 70e6602740c425f3a39cafc3e7bd6952
BLAKE2b-256 849f2ed73bd521fff0ad477a958f8db95c88abacac6bfb7ce55e5c66692d3126

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