Skip to main content

Markdown-ADF converter for Python.

Project description

md-adf

Typed Python implementation of the Markdown-ADF converter.

Install

pip install md-adf

Requires Python 3.10 or newer.

API

from md_adf import (
    adf_to_markdown,
    markdown_to_adf,
    parse_adf,
    validate_adf,
)

markdown_result = adf_to_markdown(adf_document)
print(markdown_result.value)
print(markdown_result.diagnostics)

adf_result = markdown_to_adf("## Hello\n\nThis is **ADF**.")
print(adf_result.value)

Results have this shape:

@dataclass(frozen=True)
class ConversionResult(Generic[T]):
    value: T
    diagnostics: list[Diagnostic]

Current ConversionOptions support:

  • markdown_dialect: only gfm is supported; other values are rejected. Dict options may also use markdownDialect.
  • profile: jira, confluence, and portableMarkdown are accepted for API and CLI parity, but do not change Phase 1 conversion behavior yet.
  • validate_adf: defaults to True; set to False to skip pinned schema validation for ADF-to-Markdown input. Dict options may also use validateAdf.
  • normalize_adf: accepted for future normalization controls. It is currently a no-op because Phase 1 Markdown-to-ADF output is already normalized where supported. Dict options may also use normalizeAdf.

ADF-to-Markdown returns a string with trailing whitespace trimmed and no final newline. The CLI writes that string exactly.

CLI

md-adf to-md input.adf.json --output output.md
md-adf to-adf input.md --output output.adf.json
md-adf validate-adf input.adf.json
cat input.md | md-adf to-adf --profile jira

Supported profiles are jira, confluence, and portableMarkdown. Diagnostics are emitted as JSON lines to stderr.

Current Support

  • ADF validation/parsing against a pinned ADF schema.
  • ADF to Markdown for doc, paragraph, heading, blockquote, bulletList, orderedList, listItem, codeBlock, rule, simple GFM tables, task lists, media link/text fallback, rich inline text fallback for mention, emoji, date, and status, text, and hardBreak.
  • Markdown to ADF for paragraphs, headings, block quotes, lists, GFM task lists, code blocks, thematic breaks, GFM tables, text, hard breaks, soft breaks, links, images as link text fallback, and raw HTML as text fallback.
  • Marks for strong, em, strike, code, and link.
  • Structured diagnostics for invalid ADF roots, unsupported ADF nodes/marks, invalid containers, invalid link marks, complex table omission, task-list fallback, image/media fallback, rich inline fallback, and dropped rich inline attributes.

Known Limitations

  • ADF to Markdown only renders simple rectangular tables as GFM pipe tables; complex tables are omitted with diagnostics.
  • Media is represented as Markdown link/text fallback; no media URL resolver or image emission exists yet.
  • Markdown to ADF maps images to linked text fallback instead of ADF media nodes.
  • Mixed or complex GFM task lists may fall back to ordinary list items with diagnostics.
  • ADF to Markdown renders mentions, emoji, dates, and statuses as text fallbacks; Markdown to ADF keeps that text as normal text and does not recreate rich inline node IDs.
  • ADF to Markdown does not yet render panels, expands, cards, layout nodes, extensions, or color/underline/subscript/superscript marks.
  • Markdown raw HTML is preserved as text fallback; it is not interpreted into rich ADF.
  • Unsupported ADF nodes are omitted with diagnostics.
  • Markdown parser AST access is not exposed as public API yet; conversion uses real Markdown parsers internally.

Development

poetry -C packages/python run python ../../tools/conformance/run-python.py
poetry -C packages/python run pytest
poetry -C packages/python run ruff check --config ../../pyproject.toml src tests ../../tools/conformance/run-python.py
poetry -C packages/python run mypy --config-file ../../pyproject.toml src tests ../../tools/conformance/run-python.py
npm run test:packages

Shared conformance fixtures live in ../../fixtures and are run by the root just test-python command.

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

md_adf-0.1.3.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

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

md_adf-0.1.3-py3-none-any.whl (51.1 kB view details)

Uploaded Python 3

File details

Details for the file md_adf-0.1.3.tar.gz.

File metadata

  • Download URL: md_adf-0.1.3.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.4 Darwin/24.6.0

File hashes

Hashes for md_adf-0.1.3.tar.gz
Algorithm Hash digest
SHA256 85248c15051abe6abfd0d3c612df2b116eeec1365e35531e507c3182203804c3
MD5 1c21116ae3685ad6ab329284dc468fc8
BLAKE2b-256 35f56c8dc1b026ccb7976941d4dd3644b76d0df204cd57399f9c432229464db5

See more details on using hashes here.

File details

Details for the file md_adf-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: md_adf-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 51.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.4 Darwin/24.6.0

File hashes

Hashes for md_adf-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 23db84bb1385263b3798a9baca2313c569a7c982e51194f448bd52dd419b8af5
MD5 f90f0f4cbc73c9d5545038b9cf3c006e
BLAKE2b-256 45ce3cd9c0e21f498351bd7f73ae8317b46cd0bcc8bb0a6e3f7e6a0971c812bc

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