Skip to main content

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.

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/

results.png

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

html_to_adf-0.1.1.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

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

html_to_adf-0.1.1-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file html_to_adf-0.1.1.tar.gz.

File metadata

  • Download URL: html_to_adf-0.1.1.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for html_to_adf-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6725700f693f3a1ffa80b15bac87f3da55ef3c733fbff2b068f069d6d1893ddf
MD5 06a3b1fad1512b2d5376bb2c68b3dc9f
BLAKE2b-256 68af4022f63cceb0be57692352d44be3eb08eba7095bcc8e6465ed45f8ad475f

See more details on using hashes here.

File details

Details for the file html_to_adf-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: html_to_adf-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for html_to_adf-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 518696d554a1af893e6e2b7a2189c7daf5ab986bfd1bb39ec1cc210031907443
MD5 36e9e80357def997c7f456cbed8c4410
BLAKE2b-256 c647cae273e4779e05f51905883bd6aa16e8b1f5f382bb405980829766af844e

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