ADF Conversion

Comprehensive guide to Atlassian Document Format (ADF) conversion in the MCP Confluence ADF system.

Overview

The Atlassian Document Format (ADF) is a JSON-based format used by Confluence to store and render rich content. The MCP server handles automatic conversion between Markdown and ADF, enabling seamless content creation and editing.

graph LR
    A[Markdown Input] --> B[Parser Engine]
    B --> C[AST Generation]
    C --> D[ADF Node Mapping]
    D --> E[ADF Document]
    E --> F[Confluence Storage]
    
    style A fill:#e3f2fd
    style E fill:#e8f5e8
    style F fill:#fff3e0

ADF Structure and Components

Document Structure

ADF documents follow a hierarchical node structure:

Core Node Types

Text Nodes

Paragraph Nodes

Heading Nodes

Markdown to ADF Mapping

Basic Text Formatting

Markdown
ADF Node
Description

**bold**

text with strong mark

Bold text

*italic*

text with em mark

Italic text

`code`

text with code mark

Inline code

~~strike~~

text with strike mark

Strikethrough

Headers

Markdown
ADF Structure

# H1

heading level 1

## H2

heading level 2

### H3

heading level 3

#### H4

heading level 4

##### H5

heading level 5

###### H6

heading level 6

ADF Example:

Lists

Unordered Lists

Markdown:

ADF:

Ordered Lists

Markdown:

ADF:

Code Blocks

Markdown:

Markdown:

ADF:

Advanced ADF Components

Panels (Callouts)

Panels are special ADF components for highlighting information.

Info Panel

Markdown:

ADF:

Warning Panel

Markdown:

ADF:

Success Panel

Markdown:

ADF:

Note Panel

Markdown:

ADF:

Expandable Content (Expand)

Markdown:

ADF:

Tables

Markdown:

ADF:

Conversion Process

1. Markdown Parsing

The conversion process begins with parsing Markdown input:

Parsing Steps:

  1. Tokenization: Break Markdown into tokens

  2. AST Generation: Create Abstract Syntax Tree

  3. Validation: Check for supported elements

  4. Preprocessing: Handle custom syntax extensions

2. AST to ADF Mapping

Transform the Markdown AST into ADF nodes:

Mapping Algorithm:

3. ADF Document Assembly

Combine individual nodes into a complete ADF document:

4. Validation and Optimization

Validation Checks:

  • Schema compliance

  • Node relationship validity

  • Content integrity

  • Size limitations

Optimization Steps:

  • Remove redundant nodes

  • Merge adjacent text nodes

  • Optimize mark application

  • Compress whitespace

Custom Markdown Extensions

Panel Syntax

The system supports custom Markdown syntax for Confluence panels:

Conversion Process:

  1. Parse custom fence syntax

  2. Extract panel type and title attributes

  3. Generate ADF panel node

  4. Process panel content recursively

Expandable Syntax

Enhanced support for expandable sections:

Status Macros

Convert status indicators to Confluence status macros:

ADF Output:

Error Handling

Common Conversion Errors

Unsupported Markdown Elements

Invalid Panel Syntax

Malformed Tables

Error Recovery Strategies

Graceful Degradation:

Content Preservation:

  • Maintain original text content

  • Add conversion warnings

  • Provide manual editing suggestions

  • Log issues for review

Performance Optimization

Conversion Speed

Optimization Strategies:

  1. Streaming Processing: Process large documents in chunks

  2. Caching: Cache frequently converted patterns

  3. Parallel Processing: Convert independent sections concurrently

  4. Lazy Loading: Defer complex node processing

Performance Metrics:

Memory Management

Memory Optimization:

  • Process documents in streaming fashion

  • Release AST memory after conversion

  • Use object pooling for frequently created nodes

  • Implement garbage collection hints

Quality Assurance

Conversion Validation

Multi-level Validation:

Validation Layers:

  1. Markdown Syntax: Valid Markdown structure

  2. AST Integrity: Well-formed abstract syntax tree

  3. ADF Schema: Compliant ADF document structure

  4. Content Quality: Meaningful, complete content

Testing Strategy

Automated Tests:

Test Categories:

  • Unit tests for individual node conversion

  • Integration tests for complete document conversion

  • Performance tests for large documents

  • Regression tests for known issues

Integration with Extended Markdown ADF Parser

Library Integration

The MCP server integrates with the extended-markdown-adf-parser library for robust conversion:

Configuration Options

Conversion Settings:

Extension Points

Custom Node Handlers:

Troubleshooting Guide

Diagnosis Tools

Conversion Debug Mode:

Debug Information:

  • Markdown parsing steps

  • AST structure

  • Node conversion process

  • ADF validation results

  • Error stack traces

Common Issues and Solutions

Content Loss During Conversion

Symptoms: Missing text or formatting in converted content Diagnosis: Check for unsupported Markdown elements Solution: Use supported syntax or custom extensions

ADF Schema Violations

Symptoms: Confluence rejects the ADF document Diagnosis: Validate ADF structure against schema Solution: Fix node relationships and attributes

Performance Issues

Symptoms: Slow conversion for large documents Diagnosis: Monitor conversion metrics and memory usage Solution: Enable streaming mode or split large documents

Panel Conversion Errors

Symptoms: Panels not rendering correctly in Confluence Diagnosis: Check panel syntax and type attributes Solution: Use standard panel types and proper formatting

Recovery Procedures

Partial Conversion Recovery:

Best Practices

Markdown Authoring

For Optimal Conversion:

  • Use standard Markdown syntax when possible

  • Leverage supported panel syntax for rich content

  • Test conversion with sample content

  • Validate ADF output before publishing

Formatting Guidelines:

  • Use consistent heading hierarchy

  • Properly format code blocks with language tags

  • Structure tables with clear headers

  • Use semantic markup for emphasis

Content Organization

Document Structure:

  • Start with clear headings

  • Use panels for important information

  • Group related content logically

  • Include navigation elements

Rich Content Usage:

  • Info panels for helpful tips

  • Warning panels for critical information

  • Success panels for positive outcomes

  • Note panels for additional context

Performance Considerations

Large Document Handling:

  • Split very large documents into sections

  • Use streaming conversion when available

  • Monitor memory usage during conversion

  • Cache frequently converted content

Future Enhancements

Planned Features

  1. Enhanced Extensions

    • Support for more Confluence macros

    • Custom block type definitions

    • Advanced table features

  2. Performance Improvements

    • Streaming conversion for large documents

    • Parallel processing optimization

    • Enhanced caching strategies

  3. Quality Enhancements

    • Better error recovery

    • Content quality scoring

    • Automated content suggestions

  4. Integration Features

    • Direct Confluence macro support

    • Enhanced media handling

    • Real-time conversion preview

Next Steps

Last updated