Skip to content

Conversation

@codegen-sh
Copy link
Contributor

@codegen-sh codegen-sh bot commented Jun 12, 2025

Overview

This PR adds a comprehensive markdown to ADF (Atlassian Document Format) adapter module to the Codegen backend. The adapter converts standard Markdown text to ADF JSON structure, which is used by Atlassian products like Jira and Confluence.

What's Added

📦 New Module: src/codegen/shared/markdown_adf/

  • adapter.py - Main MarkdownToADFAdapter class with conversion logic
  • adf_types.py - Comprehensive type definitions for ADF document structure
  • __init__.py - Module exports and public API
  • README.md - Detailed documentation with usage examples

🧪 Comprehensive Test Suite

  • tests/shared/test_markdown_adf_adapter.py - 20+ test cases covering:
    • Basic text and paragraph conversion
    • Headings (H1-H6)
    • Inline formatting (bold, italic, code, links, strikethrough)
    • Code blocks with language detection
    • Lists (bullet and ordered)
    • Blockquotes and horizontal rules
    • Complex nested structures
    • Error handling and edge cases

📋 Dependencies

  • Added markdown>=3.4.0 to pyproject.toml

Supported Markdown Elements

Markdown ADF Node/Mark Description
# Heading heading Headings H1-H6
**bold** strong mark Bold text
*italic* em mark Italic text
`code` code mark Inline code
[link](url) link mark Hyperlinks
code codeBlock Code blocks with language detection
- item bulletList Bullet lists
1. item orderedList Numbered lists
> quote blockquote Block quotes
--- rule Horizontal rules

Usage Example

from codegen.shared.markdown_adf import MarkdownToADFAdapter

adapter = MarkdownToADFAdapter()

markdown = """
# Hello World

This is a paragraph with **bold** and *italic* text.

```python
def greet(name):
    print(f"Hello, {name}!")
  • Item 1
  • Item 2
    """

adf_document = adapter.convert(markdown)

Returns properly structured ADF JSON


## Key Features

✅ **Robust Error Handling** - Gracefully handles malformed markdown  
✅ **Type Safety** - Comprehensive TypedDict definitions for ADF structure  
✅ **Language Detection** - Automatic language detection for code blocks  
✅ **Nested Structures** - Support for complex nested lists and formatting  
✅ **Extensible Design** - Easy to add support for additional markdown elements  

## Testing

All tests pass and cover:
- Basic conversion scenarios
- Complex nested structures  
- Error handling with malformed input
- Edge cases and empty input
- Mixed formatting combinations

## Future Enhancements

The module is designed to be easily extensible for:
- Table support
- Image and media handling  
- Custom ADF node types (panels, mentions, etc.)
- Configuration options for conversion behavior

---

[💻 View my work](https://codegen.sh/agent/trace/35616) • [About Codegen](https://codegen.com)

- Created comprehensive markdown to ADF converter in src/codegen/shared/markdown_adf/
- Supports all common markdown elements: headings, paragraphs, lists, code blocks, inline formatting
- Includes type definitions for ADF document structure
- Added comprehensive test suite with 20+ test cases
- Added detailed documentation and usage examples
- Added markdown>=3.4.0 dependency to pyproject.toml

The adapter converts markdown text to Atlassian Document Format (ADF) JSON structure,
which is used by Jira, Confluence, and other Atlassian products.
@codegen-sh codegen-sh bot requested review from a team and codegen-team as code owners June 12, 2025 06:16
@codecov
Copy link

codecov bot commented Jun 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants