adf-bridge 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. adf_bridge-0.1.0/CONTRIBUTING.md +13 -0
  2. adf_bridge-0.1.0/LICENSE +21 -0
  3. adf_bridge-0.1.0/MANIFEST.in +6 -0
  4. adf_bridge-0.1.0/PKG-INFO +146 -0
  5. adf_bridge-0.1.0/README.md +121 -0
  6. adf_bridge-0.1.0/THIRD_PARTY_NOTICES.md +230 -0
  7. adf_bridge-0.1.0/docs/api.md +55 -0
  8. adf_bridge-0.1.0/docs/diagnostics.md +82 -0
  9. adf_bridge-0.1.0/docs/index.md +12 -0
  10. adf_bridge-0.1.0/docs/schema-and-security.md +82 -0
  11. adf_bridge-0.1.0/docs/support-matrix.md +90 -0
  12. adf_bridge-0.1.0/pyproject.toml +65 -0
  13. adf_bridge-0.1.0/setup.cfg +4 -0
  14. adf_bridge-0.1.0/src/adf_bridge/__init__.py +44 -0
  15. adf_bridge-0.1.0/src/adf_bridge/_errors.py +56 -0
  16. adf_bridge-0.1.0/src/adf_bridge/_jira_profile.py +99 -0
  17. adf_bridge-0.1.0/src/adf_bridge/_markdown.py +733 -0
  18. adf_bridge-0.1.0/src/adf_bridge/_renderer.py +1634 -0
  19. adf_bridge-0.1.0/src/adf_bridge/_resolved_images.py +57 -0
  20. adf_bridge-0.1.0/src/adf_bridge/_schema.py +177 -0
  21. adf_bridge-0.1.0/src/adf_bridge/_types.py +41 -0
  22. adf_bridge-0.1.0/src/adf_bridge/_verification.py +241 -0
  23. adf_bridge-0.1.0/src/adf_bridge/data/THIRD_PARTY_NOTICES.md +230 -0
  24. adf_bridge-0.1.0/src/adf_bridge/data/adf-schema.json +2984 -0
  25. adf_bridge-0.1.0/src/adf_bridge/data/schema-provenance.json +18 -0
  26. adf_bridge-0.1.0/src/adf_bridge/py.typed +0 -0
  27. adf_bridge-0.1.0/src/adf_bridge.egg-info/PKG-INFO +146 -0
  28. adf_bridge-0.1.0/src/adf_bridge.egg-info/SOURCES.txt +31 -0
  29. adf_bridge-0.1.0/src/adf_bridge.egg-info/dependency_links.txt +1 -0
  30. adf_bridge-0.1.0/src/adf_bridge.egg-info/requires.txt +2 -0
  31. adf_bridge-0.1.0/src/adf_bridge.egg-info/top_level.txt +1 -0
  32. adf_bridge-0.1.0/tests/test_conversion.py +1732 -0
  33. adf_bridge-0.1.0/tests/test_managed_images.py +251 -0
@@ -0,0 +1,13 @@
1
+ # Contributing
2
+
3
+ Use Python 3.11+ and uv. Keep changes focused on the documented v0.1 profile;
4
+ do not add a profile registry, network integration, or public ADF model layer.
5
+
6
+ ```sh
7
+ uv sync --all-groups
8
+ make check-ci
9
+ ```
10
+
11
+ Before changing the bundled schema, update it and `schema-provenance.json`
12
+ together, retain the Atlassian notice, verify its SHA-256 and local-only
13
+ references, and review resulting validation/profile changes.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 adf-bridge contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ include LICENSE
2
+ include THIRD_PARTY_NOTICES.md
3
+ include CONTRIBUTING.md
4
+ recursive-include docs *.md
5
+ recursive-include src/adf_bridge/data *.json *.md
6
+ include src/adf_bridge/py.typed
@@ -0,0 +1,146 @@
1
+ Metadata-Version: 2.4
2
+ Name: adf-bridge
3
+ Version: 0.1.0
4
+ Summary: Focused, pure-Python conversion between Markdown and Jira ADF
5
+ Author: adf-bridge contributors
6
+ License-Expression: MIT
7
+ Project-URL: Documentation, https://github.com/en-ver/adf-bridge#readme
8
+ Project-URL: Repository, https://github.com/en-ver/adf-bridge
9
+ Project-URL: Issues, https://github.com/en-ver/adf-bridge/issues
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Topic :: Text Processing :: Markup
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ License-File: THIRD_PARTY_NOTICES.md
22
+ Requires-Dist: fastjsonschema<2.23,>=2.22.2
23
+ Requires-Dist: mistune<3.4,>=3.3.4
24
+ Dynamic: license-file
25
+
26
+ # adf-bridge
27
+
28
+ `adf-bridge` is a small, pure-Python bridge between portable GFM Markdown and
29
+ a focused Jira-oriented subset of Atlassian Document Format (ADF). It returns
30
+ ordinary JSON-compatible dictionaries rather than model classes.
31
+
32
+ ```python
33
+ from adf_bridge import adf_to_markdown, markdown_to_adf
34
+
35
+ created = markdown_to_adf("Hello [~accountId:557057:User-AbC]")
36
+ assert created.value["type"] == "doc"
37
+ assert adf_to_markdown(created.value).value == "Hello [~accountId:557057:User-AbC]"
38
+ ```
39
+
40
+ ## API and behavior
41
+
42
+ - `markdown_image_urls(markdown, *, strict=False) -> ConversionResult[tuple[str, ...]]`
43
+ - `markdown_to_adf(markdown, *, strict=False, resolved_images=()) -> ConversionResult[AdfDocument]`
44
+ - `adf_to_markdown(document, *, strict=False) -> ConversionResult[str]`
45
+ - `validate_adf(document) -> None`
46
+ - `verify_jira_media_readback(submitted, persisted, *, resolved_images) -> None`
47
+
48
+ A `ConversionResult` holds `value` and an ordered tuple of structured
49
+ `Diagnostic` values. `strict=True` converts any readable-degradation warning
50
+ into `LossyConversionError` after conversion completes. Invalid ADF, unknown
51
+ constructs, and out-of-profile features always raise project-owned errors.
52
+
53
+ Blank CommonMark Markdown becomes the canonical sole empty root paragraph.
54
+ Empty ADF documents also render as an empty string. GFM output is canonicalized
55
+ and has no terminal newline; exact source spelling is not round-tripped.
56
+
57
+ ## v0.1 profile
58
+
59
+ Direct support covers paragraphs, headings, blockquotes, lists, code blocks,
60
+ hard breaks, rules, tables, text, strong/emphasis/strike/code/link marks, and
61
+ canonical Jira account-ID mentions. Mention IDs remain opaque; `&`, `<`, and
62
+ `>` are source-encoded safely. Adjacent marked text uses a local mark stack, so
63
+ shared presentation marks stay open across supported overlaps. Basic table-cell
64
+ paragraphs and hard breaks are flattened through exact lowercase `<br>` with one
65
+ warning per affected cell. Dates, emoji, inline cards, status, expand/panel, and
66
+ unmarked media have readable warning-producing fallbacks. Inline-code line
67
+ endings normalize to spaces with a diagnostic; code-block text canonicalizes to
68
+ LF with one trailing newline when nonempty and warns only when that changes its
69
+ semantic text.
70
+
71
+ Link, image, and card labels entity-encode their nested literal syntax, so URL
72
+ labels with Markdown punctuation round-trip without retained escape backslashes.
73
+ Inside table cells, nested syntax-owned values including mention IDs and link
74
+ titles entity-encode pipes before GFM table parsing. Form feed is entity-encoded
75
+ losslessly. Bridge-generated direct link, card, and external-media destinations
76
+ are opaque values: a reversible CommonMark entity encoding preserves their exact
77
+ supported characters without URL normalization. Caller-authored Markdown
78
+ autolinks and used reference links instead use CommonMark/Mistune URL
79
+ normalization; their raw source spelling is not an opaque-destination
80
+ preservation contract and produces no diagnostic. Ordinary and readable-fallback
81
+ text containing U+0000 normalizes to U+FFFD with a warning; mention IDs
82
+ containing U+0000 are rejected to preserve their opaque identity. Markdown
83
+ consisting only of reference definitions produces no visible ADF content and
84
+ warns with `markdown.reference_definitions_discarded`. Values containing a character that
85
+ HTML5 character references cannot preserve (such as NUL) are fatal at the
86
+ bridge-generated destination attribute. Presentation marks with an
87
+ unrepresentable Unicode-whitespace boundary (such as VT or NEL) preserve their
88
+ text but are discarded with a warning. Ordinary/root VT and NEL text remains
89
+ exact; at list or table edges a reversible source entity is used when available,
90
+ or `adf.boundary_whitespace_normalized` documents unavoidable loss. Empty link
91
+ titles and titles containing control characters are intentionally omitted with
92
+ an attribute-discard warning.
93
+
94
+ Block alignment and indentation marks, and every mark on `media`,
95
+ `mediaSingle`, or `mediaGroup`, are fatal because v0.1 has no unambiguous GFM
96
+ placement for them. Linked inline code containing `[` or `]` is also fatal:
97
+ Mistune/CommonMark cannot preserve those code-label characters exactly. A
98
+ nonterminal heading hard break and an ordered list whose generated sequence
99
+ exceeds nine-digit markers are rejected rather than silently changing block
100
+ structure. Every break in a terminal paragraph or heading hard-break run is
101
+ discarded with a warning because portable GFM has no semantic representation for
102
+ it; table-cell breaks retain their `<br>` flattening policy. A heading's literal
103
+ ATX closing-hash candidate is source-encoded to preserve trailing `#` text.
104
+ Only the canonical sole root empty paragraph represents empty visible Markdown;
105
+ other ordinary empty ADF paragraphs are fatal. The exact empty paragraph shapes
106
+ produced by GFM empty list items and table cells render as canonical empty list
107
+ markers and cells. Adjacent same-kind lists use equivalent alternating GFM
108
+ markers to remain distinct. Empty Markdown link labels, linked images, images
109
+ in headings or table cells, and unsupported table-cell shapes are rejected
110
+ rather than silently dropped.
111
+
112
+ See the [support matrix](https://github.com/en-ver/adf-bridge/blob/main/docs/support-matrix.md)
113
+ and [diagnostics guide](https://github.com/en-ver/adf-bridge/blob/main/docs/diagnostics.md)
114
+ for details. `markdown_image_urls()` uses the same focused parser as conversion
115
+ and returns supported image destinations in source order. Callers can supply
116
+ immutable `ResolvedJiraImage(source_url, media_id, collection)` values to convert
117
+ exact matching image URLs into Jira `file` media; unmapped URLs remain external.
118
+ Mappings are data only: invalid, unused, duplicate-source, or duplicate Jira
119
+ media-identity (`media_id`, `collection`) entries fail, and no URL normalization
120
+ or Jira enrichment is performed. Markdown owns alt text for every occurrence.
121
+ Managed media cannot render back to its original attachment-content URL.
122
+ `verify_jira_media_readback()` narrowly checks persisted managed media at the same
123
+ ADF paths, permitting only known Jira local IDs, sizing, occurrence keys, and
124
+ nonnegative media dimensions. This package does not perform Jira lookups, network
125
+ operations, CLI work, or plugin registration.
126
+
127
+ ## Schema and licenses
128
+
129
+ The wheel bundles the exact unmodified `@atlaskit/adf-schema` 57.3.4 full JSON
130
+ Schema. It is checksum-verified, requires local-only `$ref` values, and is
131
+ compiled once with defaults disabled using `fastjsonschema`. Project code is
132
+ MIT licensed. The bundled Atlassian schema is Apache-2.0; its attribution and
133
+ full license are in
134
+ [THIRD_PARTY_NOTICES.md](https://github.com/en-ver/adf-bridge/blob/main/THIRD_PARTY_NOTICES.md).
135
+
136
+ ## Development
137
+
138
+ Use [uv](https://docs.astral.sh/uv/):
139
+
140
+ ```sh
141
+ uv sync --all-groups
142
+ make check-ci
143
+ ```
144
+
145
+ See [CONTRIBUTING.md](https://github.com/en-ver/adf-bridge/blob/main/CONTRIBUTING.md)
146
+ for the focused validation commands.
@@ -0,0 +1,121 @@
1
+ # adf-bridge
2
+
3
+ `adf-bridge` is a small, pure-Python bridge between portable GFM Markdown and
4
+ a focused Jira-oriented subset of Atlassian Document Format (ADF). It returns
5
+ ordinary JSON-compatible dictionaries rather than model classes.
6
+
7
+ ```python
8
+ from adf_bridge import adf_to_markdown, markdown_to_adf
9
+
10
+ created = markdown_to_adf("Hello [~accountId:557057:User-AbC]")
11
+ assert created.value["type"] == "doc"
12
+ assert adf_to_markdown(created.value).value == "Hello [~accountId:557057:User-AbC]"
13
+ ```
14
+
15
+ ## API and behavior
16
+
17
+ - `markdown_image_urls(markdown, *, strict=False) -> ConversionResult[tuple[str, ...]]`
18
+ - `markdown_to_adf(markdown, *, strict=False, resolved_images=()) -> ConversionResult[AdfDocument]`
19
+ - `adf_to_markdown(document, *, strict=False) -> ConversionResult[str]`
20
+ - `validate_adf(document) -> None`
21
+ - `verify_jira_media_readback(submitted, persisted, *, resolved_images) -> None`
22
+
23
+ A `ConversionResult` holds `value` and an ordered tuple of structured
24
+ `Diagnostic` values. `strict=True` converts any readable-degradation warning
25
+ into `LossyConversionError` after conversion completes. Invalid ADF, unknown
26
+ constructs, and out-of-profile features always raise project-owned errors.
27
+
28
+ Blank CommonMark Markdown becomes the canonical sole empty root paragraph.
29
+ Empty ADF documents also render as an empty string. GFM output is canonicalized
30
+ and has no terminal newline; exact source spelling is not round-tripped.
31
+
32
+ ## v0.1 profile
33
+
34
+ Direct support covers paragraphs, headings, blockquotes, lists, code blocks,
35
+ hard breaks, rules, tables, text, strong/emphasis/strike/code/link marks, and
36
+ canonical Jira account-ID mentions. Mention IDs remain opaque; `&`, `<`, and
37
+ `>` are source-encoded safely. Adjacent marked text uses a local mark stack, so
38
+ shared presentation marks stay open across supported overlaps. Basic table-cell
39
+ paragraphs and hard breaks are flattened through exact lowercase `<br>` with one
40
+ warning per affected cell. Dates, emoji, inline cards, status, expand/panel, and
41
+ unmarked media have readable warning-producing fallbacks. Inline-code line
42
+ endings normalize to spaces with a diagnostic; code-block text canonicalizes to
43
+ LF with one trailing newline when nonempty and warns only when that changes its
44
+ semantic text.
45
+
46
+ Link, image, and card labels entity-encode their nested literal syntax, so URL
47
+ labels with Markdown punctuation round-trip without retained escape backslashes.
48
+ Inside table cells, nested syntax-owned values including mention IDs and link
49
+ titles entity-encode pipes before GFM table parsing. Form feed is entity-encoded
50
+ losslessly. Bridge-generated direct link, card, and external-media destinations
51
+ are opaque values: a reversible CommonMark entity encoding preserves their exact
52
+ supported characters without URL normalization. Caller-authored Markdown
53
+ autolinks and used reference links instead use CommonMark/Mistune URL
54
+ normalization; their raw source spelling is not an opaque-destination
55
+ preservation contract and produces no diagnostic. Ordinary and readable-fallback
56
+ text containing U+0000 normalizes to U+FFFD with a warning; mention IDs
57
+ containing U+0000 are rejected to preserve their opaque identity. Markdown
58
+ consisting only of reference definitions produces no visible ADF content and
59
+ warns with `markdown.reference_definitions_discarded`. Values containing a character that
60
+ HTML5 character references cannot preserve (such as NUL) are fatal at the
61
+ bridge-generated destination attribute. Presentation marks with an
62
+ unrepresentable Unicode-whitespace boundary (such as VT or NEL) preserve their
63
+ text but are discarded with a warning. Ordinary/root VT and NEL text remains
64
+ exact; at list or table edges a reversible source entity is used when available,
65
+ or `adf.boundary_whitespace_normalized` documents unavoidable loss. Empty link
66
+ titles and titles containing control characters are intentionally omitted with
67
+ an attribute-discard warning.
68
+
69
+ Block alignment and indentation marks, and every mark on `media`,
70
+ `mediaSingle`, or `mediaGroup`, are fatal because v0.1 has no unambiguous GFM
71
+ placement for them. Linked inline code containing `[` or `]` is also fatal:
72
+ Mistune/CommonMark cannot preserve those code-label characters exactly. A
73
+ nonterminal heading hard break and an ordered list whose generated sequence
74
+ exceeds nine-digit markers are rejected rather than silently changing block
75
+ structure. Every break in a terminal paragraph or heading hard-break run is
76
+ discarded with a warning because portable GFM has no semantic representation for
77
+ it; table-cell breaks retain their `<br>` flattening policy. A heading's literal
78
+ ATX closing-hash candidate is source-encoded to preserve trailing `#` text.
79
+ Only the canonical sole root empty paragraph represents empty visible Markdown;
80
+ other ordinary empty ADF paragraphs are fatal. The exact empty paragraph shapes
81
+ produced by GFM empty list items and table cells render as canonical empty list
82
+ markers and cells. Adjacent same-kind lists use equivalent alternating GFM
83
+ markers to remain distinct. Empty Markdown link labels, linked images, images
84
+ in headings or table cells, and unsupported table-cell shapes are rejected
85
+ rather than silently dropped.
86
+
87
+ See the [support matrix](https://github.com/en-ver/adf-bridge/blob/main/docs/support-matrix.md)
88
+ and [diagnostics guide](https://github.com/en-ver/adf-bridge/blob/main/docs/diagnostics.md)
89
+ for details. `markdown_image_urls()` uses the same focused parser as conversion
90
+ and returns supported image destinations in source order. Callers can supply
91
+ immutable `ResolvedJiraImage(source_url, media_id, collection)` values to convert
92
+ exact matching image URLs into Jira `file` media; unmapped URLs remain external.
93
+ Mappings are data only: invalid, unused, duplicate-source, or duplicate Jira
94
+ media-identity (`media_id`, `collection`) entries fail, and no URL normalization
95
+ or Jira enrichment is performed. Markdown owns alt text for every occurrence.
96
+ Managed media cannot render back to its original attachment-content URL.
97
+ `verify_jira_media_readback()` narrowly checks persisted managed media at the same
98
+ ADF paths, permitting only known Jira local IDs, sizing, occurrence keys, and
99
+ nonnegative media dimensions. This package does not perform Jira lookups, network
100
+ operations, CLI work, or plugin registration.
101
+
102
+ ## Schema and licenses
103
+
104
+ The wheel bundles the exact unmodified `@atlaskit/adf-schema` 57.3.4 full JSON
105
+ Schema. It is checksum-verified, requires local-only `$ref` values, and is
106
+ compiled once with defaults disabled using `fastjsonschema`. Project code is
107
+ MIT licensed. The bundled Atlassian schema is Apache-2.0; its attribution and
108
+ full license are in
109
+ [THIRD_PARTY_NOTICES.md](https://github.com/en-ver/adf-bridge/blob/main/THIRD_PARTY_NOTICES.md).
110
+
111
+ ## Development
112
+
113
+ Use [uv](https://docs.astral.sh/uv/):
114
+
115
+ ```sh
116
+ uv sync --all-groups
117
+ make check-ci
118
+ ```
119
+
120
+ See [CONTRIBUTING.md](https://github.com/en-ver/adf-bridge/blob/main/CONTRIBUTING.md)
121
+ for the focused validation commands.
@@ -0,0 +1,230 @@
1
+ Third-party notices
2
+
3
+ ===================
4
+
5
+
6
+
7
+ Atlassian Document Format schema
8
+
9
+ --------------------------------
10
+
11
+ Unmodified full schema from `@atlaskit/adf-schema` 57.3.4,
12
+ `dist/json-schema/v1/full.json`.
13
+
14
+ Copyright 2019 Atlassian Pty Ltd
15
+
16
+ Licensed under the Apache License, Version 2.0 (the "License");
17
+ you may not use this file except in compliance with the License.
18
+ You may obtain a copy of the License at
19
+
20
+ http://www.apache.org/licenses/LICENSE-2.0
21
+
22
+ Unless required by applicable law or agreed to in writing, software
23
+ distributed under the License is distributed on an "AS IS" BASIS,
24
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
+ See the License for the specific language governing permissions and
26
+ limitations under the License.
27
+
28
+
29
+
30
+ Apache License
31
+ Version 2.0, January 2004
32
+ http://www.apache.org/licenses/
33
+
34
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
35
+
36
+ 1. Definitions.
37
+
38
+ "License" shall mean the terms and conditions for use, reproduction,
39
+ and distribution as defined by Sections 1 through 9 of this document.
40
+
41
+ "Licensor" shall mean the copyright owner or entity authorized by
42
+ the copyright owner that is granting the License.
43
+
44
+ "Legal Entity" shall mean the union of the acting entity and all
45
+ other entities that control, are controlled by, or are under common
46
+ control with that entity. For the purposes of this definition,
47
+ "control" means (i) the power, direct or indirect, to cause the
48
+ direction or management of such entity, whether by contract or
49
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
50
+ outstanding shares, or (iii) beneficial ownership of such entity.
51
+
52
+ "You" (or "Your") shall mean an individual or Legal Entity
53
+ exercising permissions granted by this License.
54
+
55
+ "Source" form shall mean the preferred form for making modifications,
56
+ including but not limited to software source code, documentation
57
+ source, and configuration files.
58
+
59
+ "Object" form shall mean any form resulting from mechanical
60
+ transformation or translation of a Source form, including but
61
+ not limited to compiled object code, generated documentation,
62
+ and conversions to other media types.
63
+
64
+ "Work" shall mean the work of authorship, whether in Source or
65
+ Object form, made available under the License, as indicated by a
66
+ copyright notice that is included in or attached to the work
67
+ (an example is provided in the Appendix below).
68
+
69
+ "Derivative Works" shall mean any work, whether in Source or Object
70
+ form, that is based on (or derived from) the Work and for which the
71
+ editorial revisions, annotations, elaborations, or other modifications
72
+ represent, as a whole, an original work of authorship. For the purposes
73
+ of this License, Derivative Works shall not include works that remain
74
+ separable from, or merely link (or bind by name) to the interfaces of,
75
+ the Work and Derivative Works thereof.
76
+
77
+ "Contribution" shall mean any work of authorship, including
78
+ the original version of the Work and any modifications or additions
79
+ to that Work or Derivative Works thereof, that is intentionally
80
+ submitted to Licensor for inclusion in the Work by the copyright owner
81
+ or by an individual or Legal Entity authorized to submit on behalf of
82
+ the copyright owner. For the purposes of this definition, "submitted"
83
+ means any form of electronic, verbal, or written communication sent
84
+ to the Licensor or its representatives, including but not limited to
85
+ communication on electronic mailing lists, source code control systems,
86
+ and issue tracking systems that are managed by, or on behalf of, the
87
+ Licensor for the purpose of discussing and improving the Work, but
88
+ excluding communication that is conspicuously marked or otherwise
89
+ designated in writing by the copyright owner as "Not a Contribution."
90
+
91
+ "Contributor" shall mean Licensor and any individual or Legal Entity
92
+ on behalf of whom a Contribution has been received by Licensor and
93
+ subsequently incorporated within the Work.
94
+
95
+ 2. Grant of Copyright License. Subject to the terms and conditions of
96
+ this License, each Contributor hereby grants to You a perpetual,
97
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
98
+ copyright license to reproduce, prepare Derivative Works of,
99
+ publicly display, publicly perform, sublicense, and distribute the
100
+ Work and such Derivative Works in Source or Object form.
101
+
102
+ 3. Grant of Patent License. Subject to the terms and conditions of
103
+ this License, each Contributor hereby grants to You a perpetual,
104
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
105
+ (except as stated in this section) patent license to make, have made,
106
+ use, offer to sell, sell, import, and otherwise transfer the Work,
107
+ where such license applies only to those patent claims licensable
108
+ by such Contributor that are necessarily infringed by their
109
+ Contribution(s) alone or by combination of their Contribution(s)
110
+ with the Work to which such Contribution(s) was submitted. If You
111
+ institute patent litigation against any entity (including a
112
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
113
+ or a Contribution incorporated within the Work constitutes direct
114
+ or contributory patent infringement, then any patent licenses
115
+ granted to You under this License for that Work shall terminate
116
+ as of the date such litigation is filed.
117
+
118
+ 4. Redistribution. You may reproduce and distribute copies of the
119
+ Work or Derivative Works thereof in any medium, with or without
120
+ modifications, and in Source or Object form, provided that You
121
+ meet the following conditions:
122
+
123
+ (a) You must give any other recipients of the Work or
124
+ Derivative Works a copy of this License; and
125
+
126
+ (b) You must cause any modified files to carry prominent notices
127
+ stating that You changed the files; and
128
+
129
+ (c) You must retain, in the Source form of any Derivative Works
130
+ that You distribute, all copyright, patent, trademark, and
131
+ attribution notices from the Source form of the Work,
132
+ excluding those notices that do not pertain to any part of
133
+ the Derivative Works; and
134
+
135
+ (d) If the Work includes a "NOTICE" text file as part of its
136
+ distribution, then any Derivative Works that You distribute must
137
+ include a readable copy of the attribution notices contained
138
+ within such NOTICE file, excluding those notices that do not
139
+ pertain to any part of the Derivative Works, in at least one
140
+ of the following places: within a NOTICE text file distributed
141
+ as part of the Derivative Works; within the Source form or
142
+ documentation, if provided along with the Derivative Works; or,
143
+ within a display generated by the Derivative Works, if and
144
+ wherever such third-party notices normally appear. The contents
145
+ of the NOTICE file are for informational purposes only and
146
+ do not modify the License. You may add Your own attribution
147
+ notices within Derivative Works that You distribute, alongside
148
+ or as an addendum to the NOTICE text from the Work, provided
149
+ that such additional attribution notices cannot be construed
150
+ as modifying the License.
151
+
152
+ You may add Your own copyright statement to Your modifications and
153
+ may provide additional or different license terms and conditions
154
+ for use, reproduction, or distribution of Your modifications, or
155
+ for any such Derivative Works as a whole, provided Your use,
156
+ reproduction, and distribution of the Work otherwise complies with
157
+ the conditions stated in this License.
158
+
159
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
160
+ any Contribution intentionally submitted for inclusion in the Work
161
+ by You to the Licensor shall be under the terms and conditions of
162
+ this License, without any additional terms or conditions.
163
+ Notwithstanding the above, nothing herein shall supersede or modify
164
+ the terms of any separate license agreement you may have executed
165
+ with Licensor regarding such Contributions.
166
+
167
+ 6. Trademarks. This License does not grant permission to use the trade
168
+ names, trademarks, service marks, or product names of the Licensor,
169
+ except as required for reasonable and customary use in describing the
170
+ origin of the Work and reproducing the content of the NOTICE file.
171
+
172
+ 7. Disclaimer of Warranty. Unless required by applicable law or
173
+ agreed to in writing, Licensor provides the Work (and each
174
+ Contributor provides its Contributions) on an "AS IS" BASIS,
175
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
176
+ implied, including, without limitation, any warranties or conditions
177
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
178
+ PARTICULAR PURPOSE. You are solely responsible for determining the
179
+ appropriateness of using or redistributing the Work and assume any
180
+ risks associated with Your exercise of permissions under this License.
181
+
182
+ 8. Limitation of Liability. In no event and under no legal theory,
183
+ whether in tort (including negligence), contract, or otherwise,
184
+ unless required by applicable law (such as deliberate and grossly
185
+ negligent acts) or agreed to in writing, shall any Contributor be
186
+ liable to You for damages, including any direct, indirect, special,
187
+ incidental, or consequential damages of any character arising as a
188
+ result of this License or out of the use or inability to use the
189
+ Work (including but not limited to damages for loss of goodwill,
190
+ work stoppage, computer failure or malfunction, or any and all
191
+ other commercial damages or losses), even if such Contributor
192
+ has been advised of the possibility of such damages.
193
+
194
+ 9. Accepting Warranty or Additional Liability. While redistributing
195
+ the Work or Derivative Works thereof, You may choose to offer,
196
+ and charge a fee for, acceptance of support, warranty, indemnity,
197
+ or other liability obligations and/or rights consistent with this
198
+ License. However, in accepting such obligations, You may act only
199
+ on Your own behalf and on Your sole responsibility, not on behalf
200
+ of any other Contributor, and only if You agree to indemnify,
201
+ defend, and hold each Contributor harmless for any liability
202
+ incurred by, or claims asserted against, such Contributor by reason
203
+ of your accepting any such warranty or additional liability.
204
+
205
+ END OF TERMS AND CONDITIONS
206
+
207
+ APPENDIX: How to apply the Apache License to your work.
208
+
209
+ To apply the Apache License to your work, attach the following
210
+ boilerplate notice, with the fields enclosed by brackets "[]"
211
+ replaced with your own identifying information. (Don't include
212
+ the brackets!) The text should be enclosed in the appropriate
213
+ comment syntax for the file format. We also recommend that a
214
+ file or class name and description of purpose be included on the
215
+ same "printed page" as the copyright notice for easier
216
+ identification within third-party archives.
217
+
218
+ Copyright [yyyy] [name of copyright owner]
219
+
220
+ Licensed under the Apache License, Version 2.0 (the "License");
221
+ you may not use this file except in compliance with the License.
222
+ You may obtain a copy of the License at
223
+
224
+ http://www.apache.org/licenses/LICENSE-2.0
225
+
226
+ Unless required by applicable law or agreed to in writing, software
227
+ distributed under the License is distributed on an "AS IS" BASIS,
228
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
229
+ See the License for the specific language governing permissions and
230
+ limitations under the License.
@@ -0,0 +1,55 @@
1
+ # API
2
+
3
+ ```python
4
+ from adf_bridge import (
5
+ ResolvedJiraImage,
6
+ adf_to_markdown,
7
+ markdown_image_urls,
8
+ markdown_to_adf,
9
+ validate_adf,
10
+ verify_jira_media_readback,
11
+ )
12
+
13
+ image_urls = markdown_image_urls("![diagram](https://jira.test/content/42)").value
14
+ resolution = ResolvedJiraImage(image_urls[0], "media-id", "")
15
+ result = markdown_to_adf("![diagram](https://jira.test/content/42)", resolved_images=(resolution,))
16
+ validate_adf(result.value)
17
+ verify_jira_media_readback(result.value, result.value, resolved_images=(resolution,))
18
+ markdown = adf_to_markdown(result.value).value
19
+ ```
20
+
21
+ `Diagnostic` has stable `code`, `severity`, `path`, `keyword`, and
22
+ `schema_path` fields. Messages are explanatory rather than a text-stability
23
+ contract. Schema failures raise `AdfValidationError`; package-resource or
24
+ trusted-schema failures raise `AdfSchemaError`; profile failures raise
25
+ `AdfConversionError`; strict loss raises `LossyConversionError`.
26
+
27
+ Mentions map without lookup: `[~accountId:<id>]` becomes a `mention` node with
28
+ only `attrs.id`, and renders back with the canonical `accountId` label. IDs are
29
+ opaque and may contain `&`, `<`, `>`, and `|`; the renderer source-encodes those
30
+ characters as needed (including `|` in table cells) and the parser decodes one
31
+ complete entity-reference layer before validating the ID. IDs containing
32
+ whitespace, backslashes, `]`, or U+0000 cannot be represented and fail;
33
+ identity is never normalized.
34
+
35
+ `markdown_image_urls()` performs the same parsing and profile validation as
36
+ `markdown_to_adf()` and returns image destinations in source order, including
37
+ repetitions and used reference images. It has the same diagnostics and strict-mode
38
+ behavior. `resolved_images` is a keyword-only sequence of immutable
39
+ `ResolvedJiraImage` values. Its source URLs match parser destinations exactly;
40
+ `source_url` and `media_id` must be nonempty, while `collection` may be empty.
41
+ Duplicate source URLs, duplicate Jira media identities (the same `media_id` and
42
+ `collection`), and unused mappings raise `AdfConversionError`; a non-sequence,
43
+ wrong item type, or wrong field type raises `TypeError`.
44
+ A match produces a `mediaSingle` containing `file` media with only its resolved
45
+ ID, collection, and that Markdown occurrence's nonempty alt text. The bridge does
46
+ not look up URLs or add Jira presentation attributes.
47
+
48
+ `verify_jira_media_readback()` schema-validates submitted and persisted documents
49
+ then compares only resolved file-media occurrences. It requires the same paths,
50
+ identity, layout, and alt text, rejects extra occurrences and structural changes,
51
+ and permits only Jira local IDs, a complete sizing pair, occurrence keys, and
52
+ nonnegative media dimensions. Resolution mappings must have unique source URLs
53
+ and Jira media identities; invalid mappings raise `AdfConversionError`. Otherwise,
54
+ it raises `JiraMediaVerificationError` with the first failing RFC 6901 path. This
55
+ is persistence verification, not a rendering or whole-document equality assertion.