Problem: Confluence page creation was failing with 400 Bad Request errors when using heavy markdown formatting, while simple content worked fine.
Root Cause: The markdown-to-Confluence converter was generating malformed or overly complex XHTML that Confluence's REST API rejected.
- Added regex-based markdown complexity analysis
- Automatically switches between detailed and simplified conversion strategies
- Detects patterns: headers, bold/italic, code, lists, links, images
# Two-tier conversion approach:
- _detailed_markdown_to_confluence() # For simple content
- _simple_markdown_to_confluence() # For complex content- Added try-catch blocks around conversion logic
- Fallback to simple HTML paragraph wrapping on conversion failures
- Comprehensive logging for debugging
- Line-by-line processing instead of regex-heavy approach
- Proper list grouping (
<ul>wrapping multiple<li>elements) - Correct list closure handling
- Improved bold/italic regex to avoid conflicts
- Protected inline code from other conversions
- Better link and image handling
Simple Content: ✅ Perfect formatting with full feature support Complex Content: ✅ Graceful degradation with clean HTML output Error Handling: ✅ Fallback mechanisms prevent failures HTML Passthrough: ✅ Existing HTML preserved correctly
| Feature | Before | After |
|---|---|---|
| Complex Markdown | ❌ 400 Error | ✅ Clean HTML |
| List Formatting | ✅ Proper nesting | |
| Error Recovery | ❌ Total failure | ✅ Graceful fallback |
| Code Blocks | ✅ Simple <pre> tags |
|
| Detection Logic | ✅ Regex pattern analysis |
- v0.1.9: Initial release with basic functionality
- v0.2.0: Major formatting improvements and error handling
- v0.2.1: Enhanced robustness and fallback mechanisms
The formatter now automatically handles complexity:
- Simple markdown → Full featured conversion with Confluence macros
- Complex markdown → Simplified but reliable HTML conversion
- HTML content → Unchanged passthrough
- Plain text → Wrapped in paragraph tags
Users no longer need to worry about formatting complexity causing 400 errors!
Run the test suite to verify all improvements:
python test_v0_2_0.pyVersion 0.2.1 is now available:
pip install mcp-jira-confluence==0.2.1