Skip to main content

Bidirectional converter between GitHub Flavored Markdown and Atlassian Document Format

Project description

Marklas

CI PyPI Python License

MarkdownASTADF

Installation

pip install marklas

Usage

Markdown → ADF

from marklas import to_adf

adf = to_adf("**Hello** world")

# {
#   "type": "doc",
#   "version": 1,
#   "content": [
#     {
#       "type": "paragraph",
#       "content": [
#         {"type": "text", "text": "Hello", "marks": [{"type": "strong"}]},
#         {"type": "text", "text": " world"}
#       ]
#     }
#   ]
# }

ADF → Markdown

from marklas import to_md

md = to_md(adf)

# "**Hello** world\n"

Conversion Rules

Block

ADF AST Markdown
paragraph Paragraph(children) inline content
heading (level 1-6) Heading(level, children) # ~ ######
codeBlock (language?) CodeBlock(code, language?) ```lang\ncode\n```
blockquote BlockQuote(children) > text
bulletList > listItem BulletList(items) > ListItem(children) - item
orderedList > listItem OrderedList(items, start) > ListItem(children) 1. item
taskList > taskItem BulletList > ListItem(checked=bool) - [x] / - [ ]
decisionList > decisionItem BulletList > ListItem(checked=bool) - [x] / - [ ]
rule ThematicBreak ---
table > tableRow > tableHeader/tableCell Table(head, body, alignments) GFM table
mediaSingle > media (external) Paragraph > Image(url, alt) ![alt](url)
mediaSingle > media (non-external) Paragraph > Text("[Image: id]") [Image: id]
mediaGroup > media Paragraph > Image/Text ![alt](url) / [Image: id]
panel BlockQuote(children) > text
expand / nestedExpand (title?) BlockQuote(children) (title prepended) > title\n> text
layoutSection > layoutColumn flattened blocks columns flattened
blockCard (url) Paragraph > Link(url) [url](url)
embedCard (url) Paragraph > Link(url) [url](url)

Inline

ADF AST Markdown
text Text(text) plain text
text + strong mark Strong(children) **text**
text + em mark Emphasis(children) *text*
text + strike mark Strikethrough(children) ~~text~~
text + code mark CodeSpan(code) `code`
text + link mark Link(url, children, title?) [text](url)
hardBreak HardBreak \ + newline
SoftBreak newline
mention CodeSpan(code) `@user`
emoji Text(text) :shortName:
date CodeSpan(code) `2024-01-01`
status CodeSpan(code) `status text`
inlineCard (url) Link(url) [url](url)
Image(url, alt, title?) ![alt](url)

Not Supported

Element Behavior
ADF marks: underline, textColor, backgroundColor, subsup silently ignored
ADF blocks: extension, bodiedExtension, syncBlock, bodiedSyncBlock [type] placeholder
ADF inlines: placeholder, inlineExtension, mediaInline [type] placeholder
ADF table: colspan, rowspan expanded with empty cells
ADF table: background, colwidth attributes ignored
ADF table: non-paragraph cell content [type] placeholder
Markdown: raw HTML (block, inline) silently ignored

Development

uv sync --extra dev
uv run pytest -v
uv run black src/ tests/

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.2.0.tar.gz (11.7 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.2.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for marklas-0.2.0.tar.gz
Algorithm Hash digest
SHA256 665f24ce89c7624e302b42ff71d9c005dd0c1929e7b232047b9495013cd4eae4
MD5 191efee7bb9a54d665208ed27ef112ae
BLAKE2b-256 172e5899942d22ddcaac43af9f9b55df17aad0712c92409f4ab7e5f9caa05a1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for marklas-0.2.0.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: marklas-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5be91d241cae2ead32385ea6623180a5da82c945c924495bea9e9dc8dc74391
MD5 6ba67c73142c63ea56da5ae869290c80
BLAKE2b-256 8077347d925c5d7995bcc26b3cd48548ef624b54d1970ac3d0d87dc5ab8ff109

See more details on using hashes here.

Provenance

The following attestation bundles were made for marklas-0.2.0-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