Skip to content

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.

<dependency>
<groupId>io.rocketbase.mail</groupId>
<artifactId>email-template-builder-markdown</artifactId>
<version>2.7.1</version>
</dependency>

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.

Based on commonmark-java with these extensions enabled:

  • Strikethrough~~text~~
  • Ins/underline++text++
  • Image attributes![alt](image.png){width=200 height=100}

You can hook into the HtmlRenderer setup for additional commonmark configuration:

new MarkdownLine(builder, markdown,
rendererBuilder -> rendererBuilder.softbreak("<br/>"));