Convert HTML to Atlassian Document Format (ADF) for Jira and Confluence.
Project description
html-to-adf - Convert HTML to ADF (Atlassian Document Format)
What is this?
This is a rudimentary python helper module, dedicated to producing Jira/Confluence ready ADF out of incoming HTML.
The module itself attempts to handle generalized sanitization, while cutting some corners to forcibly marshal 'whatever' text into something tangible and compatible with Jira/Confluence.
This module is focused at front-loading incoming comments and descriptions for Jira and follows out of the box a relatively strict subset of tags from HTML.
How to install
We have a pypi package now, so feel free to install through pip:
pip install html-to-adf
Dependencies
Everything here is mostly a painfully hand-rolled parser; we have one dependency which is: beautifulsoup4 non-version specific.
Supported and Converted tags
<html>
<body>
<h1>...<h6>
<head> -> Converted to a heading type
<title> -> Converted to a heading type
<div> -> Converted to a paragraph type
<p>
<table> -> Represents a tablebase
<thead> -> Represents a tablehead
<tbody> -> Represents a tablebody
<tr> -> represents a tablerow
<th> -> represents a tablecell
<td> -> represents a tablecell
Modifiers:
<b>
<strong>
<i>
<em>
<s>
<u>
We also support links and <a> tags. (The magic under the hood can break; usually defaulting to nothing happening at all or your entire line being a link)
Example:
We'll convert the following HTML to ADF:
# test.py
from html_to_adf import import_html_to_str, convert_html_to_adf, export_document
html_text = import_html_to_str("test.html")
# If you were going to send this in an API request format, you would want to structure the ADF around a 'body {}'
# adding True to: convert_html_to_adf(html_text, True) will wrap the entire contents of the dict in a body {} for your ease of use.
resulting_adf_document: dict = convert_html_to_adf(html_text)
print(resulting_adf_document)
export_document(resulting_adf_document)
<!--test.html-->
<html>
<head>
<title>Monthly Sales Report</title>
</head>
<body>
<h1>Monthly Sales Report</h1>
<p>
The following table shows <b>sales performance</b> by region for
<i>September 2025</i>.
For more info, visit our
<a href="https://example.com/reports/september">report page</a>.
</p>
<table>
<thead>
<tr>
<th>Region</th>
<th>Sales ($)</th>
<th>Growth</th>
</tr>
</thead>
<tbody>
<tr>
<td>North America</td>
<td><b>125,000</b></td>
<td><span style="color:green">+5%</span></td>
</tr>
<tr>
<td>Europe</td>
<td>98,500</td>
<td><span style="color:red">-2%</span></td>
</tr>
<tr>
<td>Asia-Pacific</td>
<td>142,750</td>
<td><u>+8%</u></td>
</tr>
</tbody>
</table>
<p>
Summary: <strong>Asia-Pacific</strong> led the month with strong growth.
<br>
Keep up the great work!
</p>
</body>
</html>
This yields the following ADF: Here's the rather large textblob To view in live time, copy that blob and float on over to the Atlassian Live Document Preview: https://developer.atlassian.com/cloud/jira/platform/apis/document/viewer/
Further development and support
This module is a creation of necessity, not passion; there's a large chance I won't update it very much, but that said if I get inspired you never know!
Feel free to drop something in the Issues section as you see them and I may visit those issues!
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 html_to_adf-0.1.2.tar.gz.
File metadata
- Download URL: html_to_adf-0.1.2.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f550ed824465d06a439852ebd634d6e89e1171561e72c92497fb93020d4666fa
|
|
| MD5 |
0b88de9a361a5ac0113bd77dc8296246
|
|
| BLAKE2b-256 |
698182cb936edf38c7b621b93301766ea80868ac5f7f0d8b615b158da6ef2a9e
|
File details
Details for the file html_to_adf-0.1.2-py3-none-any.whl.
File metadata
- Download URL: html_to_adf-0.1.2-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ac473019c94fe1bf4f8a33d7e6e401648b62fd3b739fb7539db2b2884f4c65e
|
|
| MD5 |
2bb2f38220318cc3c5f23053da23bb70
|
|
| BLAKE2b-256 |
9b29a03abe587c0099dfc16a47a8fd872f3c648dc56d814c390faffdd63f7d9b
|