✅ New cleaner syntax implemented: - [card:type] instead of [card type='type'] - [button:style](url)Text[/button] instead of [button url='...' style='...'] - Standard markdown images:  ✅ Variable protection from markdown parsing: - Variables with underscores (e.g., {order_items_table}) now protected - HTML comment placeholders prevent italic/bold parsing - All variables render correctly in preview ✅ Button rendering fixes: - Buttons work in Visual mode inside cards - Buttons work in Preview mode - Button clicks prevented in visual editor - Proper styling for solid and outline buttons ✅ Backward compatibility: - Old syntax still supported - No breaking changes ✅ Bug fixes: - Fixed order_item_table → order_items_table naming - Fixed button regex to match across newlines - Added button/image parsing to parseMarkdownBasics - Prevented button clicks on .button and .button-outline classes 📚 Documentation: - NEW_MARKDOWN_SYNTAX.md - Complete user guide - MARKDOWN_SYNTAX_AND_VARIABLES.md - Technical analysis
3.2 KiB
Converter Fixes Summary
Issues Fixed
1. ✅ Exact Event Naming - No Mapping
Problem: API used order_processing but Email templates had order_confirmed. Required a "bridge" mapping.
Solution: Renamed template methods to match API exactly:
customer_order_confirmed()→customer_order_processing()staff_order_confirmed()→staff_order_processing()customer_registered()→customer_new_customer()
Result: Direct 1:1 mapping, no confusion, clean code.
2. ✅ Markdown Converter Respects [card] Boundaries
Problem: markdownToBlocks() was splitting by double newlines (\n\n), causing:
- Raw
[/card]tags left in output - Each line with double space became a new card
##headings not rendered
Root Cause:
// OLD - WRONG
const sections = markdown.split(/\n\n+/); // Splits by double newlines!
Solution: Parse by [card]...[/card] boundaries:
// NEW - CORRECT
while (remaining.length > 0) {
const cardMatch = remaining.match(/^\[card([^\]]*)\]([\s\S]*?)\[\/card\]/);
if (cardMatch) {
// Extract content between [card] and [/card]
const content = cardMatch[2].trim();
blocks.push({ type: 'card', content });
remaining = remaining.substring(cardMatch[0].length); // Advance!
}
}
Key Changes:
- Uses regex to find
[card]...[/card]pairs - Extracts content between tags
- Advances
remainingstring after each match - No splitting by newlines
3. ⚠️ Markdown Rendering in Preview (Partial)
Current State:
- Markdown is stored in database:
## Heading\n\n**bold** - Frontend CodeEditor shows clean markdown ✅
- Preview shows markdown as-is (not converted to HTML) ❌
Why:
The preview uses htmlContent which contains [card]## Heading[/card] but doesn't convert the markdown inside to HTML.
Next Steps:
Backend PHP needs to convert markdown to HTML when rendering emails. The [card] shortcode handler should:
- Extract content
- Convert markdown to HTML
- Wrap in styled div
Files Modified
-
/includes/Email/DefaultTemplates.php- Renamed methods to match API event IDs exactly
- Updated subject keys
-
/includes/Core/Notifications/TemplateProvider.php- Removed event mapping
- Direct lookup:
$allEmailTemplates[$recipient_type][$event_id]
-
/admin-spa/src/components/EmailBuilder/converter.ts- Fixed
markdownToBlocks()to respect[card]...[/card]boundaries - Added proper string advancement
- No more double-newline splitting
- Fixed
Testing Checklist
- Event names match between API and templates
- No mapping/bridging code
- Markdown editor shows clean markdown
[/card]tags not left in output- Double newlines don't create new cards
- Preview renders markdown as HTML (needs backend fix)
- Headings show as
<h2>not##in preview - Line breaks work correctly in preview
Remaining Work
Backend Markdown Rendering:
The WordPress shortcode handler for [card] needs to convert markdown content to HTML before rendering.
Location: Likely in /includes/Email/ or /includes/Core/Notifications/
Required: A function that processes [card] shortcodes and converts their markdown content to HTML using a markdown parser.