Markdown Module
The separate email-template-builder-markdown module transpiles markdown into correctly inlined
email HTML — handy when your email content comes from user input, a CMS or translation files.
Installation
Section titled “Installation”<dependency> <groupId>io.rocketbase.mail</groupId> <artifactId>email-template-builder-markdown</artifactId> <version>2.7.1</version></dependency>implementation("io.rocketbase.mail:email-template-builder-markdown:2.7.1")MarkdownLine is a regular template line — add it via addContent(…):
EmailTemplateBuilder.EmailTemplateConfigBuilder builder = EmailTemplateBuilder.builder();
HtmlTextEmail email = builder .header().text("Newsletter").and() .addContent(new MarkdownLine(builder, "# Heading 1\n" + "This is *emphasized* and this is ~~struck through~~.\n\n" + "A regular paragraph with [a link](https://example.com).")) .copyright("rocketbase").url("https://www.rocketbase.io").and() .build();Passing the builder lets the markdown renderer pick up your TbConfiguration — headings and
paragraphs get the same inlined styles as the native text() lines.
Supported syntax
Section titled “Supported syntax”Based on commonmark-java with these extensions enabled:
- Strikethrough —
~~text~~ - Ins/underline —
++text++ - Image attributes —
{width=200 height=100}
Customizing the renderer
Section titled “Customizing the renderer”You can hook into the HtmlRenderer setup for additional commonmark configuration:
new MarkdownLine(builder, markdown, rendererBuilder -> rendererBuilder.softbreak("<br/>"));