How to handle non-valid XML in MJML (Pre-v2.0.0)
mainMJML syntax is not always strictly valid XML.
For Version 2.0.0 and later: The engine uses an HTML parser that follows official standards and can accept various HTML inputs without manual sanitization.
For versions older than 2.0.0: You must sanitize the MJML string before rendering using the FixXML method to ensure the XML parser works correctly. It is recommended to store both the original and the sanitized version if saving to a database.
// Legacy approach for versions < 2.0.0
var xml = mjmlRenderer.FixXML(text, options);
var (html, errors) = mjmlRenderer.Render(xml, options);