mrml mjml 的rust 实现

mrml 是mjml 的rust 实现,同时还提供了webassembly 的支持,当然比较强大的是mrml 同时也实现了python binding

webassembly 使用

  • 代码
const { Engine } = require("mrml");
const engine = new Engine();
const result = engine.toHtml("<mjml><mj-body>Hello World</mj-body></mjml>");
console.log(result)
  • 效果
{
  type: 'success',
  content: '<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><title></title><!--[if !mso]><!--><meta http-equiv="X-UA-Compatible" content="IE=edge"><!--<![endif]--><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1">\n' +
    '<style type="text/css">\n' +
    '#outlook a { padding: 0; }\n' +
    'body { margin: 0; padding: 0; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }\n' +
    'table, td { border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; }\n' +
    'img { border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; }\n' +
    'p { display: block; margin: 13px 0; }\n' +
    '</style>\n' +
    '<!--[if mso]>\n' +
    '<noscript>\n' +
    '<xml>\n' +
    '<o:OfficeDocumentSettings>\n' +
    '  <o:AllowPNG/>\n' +
    '  <o:PixelsPerInch>96</o:PixelsPerInch>\n' +
    '</o:OfficeDocumentSettings>\n' +
    '</xml>\n' +
    '</noscript>\n' +
    '<![endif]-->\n' +
    '<!--[if lte mso 11]>\n' +
    '<style type="text/css">\n' +
    '.mj-outlook-group-fix { width:100% !important; }\n' +
    '</style>\n' +
    '<![endif]-->\n' +
    '</head><body style="word-spacing:normal;"><div>Hello World</div></body></html>'
}

说明

mrml 提供的python binding 也是比较方便的,很值得试用

参考资料

https://github.com/jdrouet/mrml
https://documentation.mjml.io/
https://github.com/mjmlio/mjml

posted on   荣锋亮  阅读(7)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2022-12-28 gitlab 集成的一些SAST安全扫描工具
2022-12-28 dremio ClassCompilerSelector 简单说明
2022-12-28 dremio SabotContext 简单说明
2021-12-28 juicefs 多s3 bucket 使用
2021-12-28 juicefs s3 gateway 试用
2020-12-28 记一次mysql 异常停电数据库损坏恢复的方法
2020-12-28 go plugins 容器构建

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示