Convert Markdown to Atlassian Document Format (ADF)
Project description
md2adf
Convert Markdown to Atlassian Document Format (ADF) — the JSON format required by Jira and Confluence REST APIs for rich text.
Installation
pip install md2adf
Usage
from md2adf import convert
adf = convert("**Hello** world")
# {
# "version": 1,
# "type": "doc",
# "content": [
# {
# "type": "paragraph",
# "content": [
# {"type": "text", "text": "Hello", "marks": [{"type": "strong"}]},
# {"type": "text", "text": " world"}
# ]
# }
# ]
# }
Use it with the Jira API:
import requests
from md2adf import convert
requests.post(
"https://your-domain.atlassian.net/rest/api/3/issue/PROJ-123/comment",
json={"body": convert("Fixed the **bug** in `parse_config()`")},
auth=("user@example.com", "api-token"),
)
Supported Markdown
| Feature | Markdown | ADF Node |
|---|---|---|
| Paragraphs | plain text | paragraph |
| Headings | # H1 ... ###### H6 |
heading |
| Bold | **bold** |
strong mark |
| Italic | _italic_ |
em mark |
| Strikethrough | ~~deleted~~ |
strike mark |
| Inline code | `code` |
code mark |
| Links | [text](url) |
link mark |
| Images |  |
link mark (fallback) |
| Code blocks | ```lang |
codeBlock |
| Bullet lists | - item |
bulletList |
| Ordered lists | 1. item |
orderedList |
| Nested lists | indented items | nested list nodes |
| Blockquotes | > text |
blockquote |
| Horizontal rules | --- |
rule |
| Hard line breaks | trailing |
hardBreak |
| Tables (GFM) | | a | b | |
table |
Nested inline formatting works correctly — **bold _and italic_ text** produces three text nodes with the right combination of marks.
How It Works
- Parse markdown with mistune in AST mode
- Walk the AST tree recursively, accumulating inline marks (bold, italic, link, etc.)
- Flatten marks onto leaf text nodes — solving the nested-marks problem that makes naive HTML-style rendering impossible for ADF
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file md2adf-0.1.0.tar.gz.
File metadata
- Download URL: md2adf-0.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74611993990c022e9ce0d2e922fe886540fa78f5f705279902cfd0ab52384574
|
|
| MD5 |
d3aea4f574df781a160578a18a42cafd
|
|
| BLAKE2b-256 |
5a52d7b672c8a0929edd471afdae59e87c62e3bedb9c8c6175f8a34da76e1de0
|
File details
Details for the file md2adf-0.1.0-py3-none-any.whl.
File metadata
- Download URL: md2adf-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4702651687ef5d5bbd2a26d242b4ef83e96f9924db680e652f6eb9aba14376a2
|
|
| MD5 |
ee3b1cb94d120b2282b1718a667e68e0
|
|
| BLAKE2b-256 |
10fe6448469e9efe811453b77f67c3da011acab694019af9e3cc22c92d36c4d0
|