How can SIL convert Jira wiki markup to HTML markup to make emails readable

Hello!

We had a question in Moscow Atlassian User Group, how to make wiki markup be well formatted in a email using SIL.

Problem

Suppose, we have an issue in Jira with a table in the description of this issue:

Let’s send the description of this issue by email with the following SIL code:

JEmailMessage email;
email.to = {"alex@gmail.com"};
email.subject = "Email to Santa";
email.message = description;
sendEmail(email);

The email will look like this:

As we can see it is hardly readable because of some symbols, which are not visible in Jira. This symbols are called wiki markup.

What is wiki markup?

First of all it is needed to say that text fields in Jira can support wiki markup or not. It is easy to define if a text field supports wiki markup. You can say it from the menu for the field when you try to edit the field. Here is how the menu looks for a text field which supports wiki markup:

Here is a text field which does not support wiki markup:

If we have a text field with support of wiki markup and we want to make a table or bold font we can add wiki markup symbols to the text. For example, to make a font cursive and bold we need to place our text between _* symbols: _*our text*_. To make a table we need to add the | sign and so on. Or you can use the menu for the field and these symbols will be added for you automatically.

Then we want to send the contents of the text field by email. When we get the email our email agent does not know how to render this text because the email agent does not have a wiki render engine, that is why our text is difficult to read. But most email agents can render HTML markup, that is why it would be great to convert our wiki markup to HTML markup.

Solution

The good news is that SIL has already a routine for converting HTML markup to wiki markup called renderWiki.

We need to change our code to this one:

JEmailMessage email;
email.to = {"alex@gmail.com"};
email.subject = "Email to Santa";
email.message = renderWiki(description);
sendEmail(email);

And our email looks like this:

It is readable!

Leave a Reply

%d bloggers like this: