New to Telerik Reporting? Download free 30-day trial

Use Markdown in Telerik Reporting

Environment

Product Reporting

Description

I want to use Markdown content from Azure DevOps wiki pages in Telerik reports. Markdown is not directly supported in Telerik Reporting, and I need a way to display the content within the report somehow.

Solution

Telerik Reporting does not have native support for rendering markdown syntax directly. However, you can use the HtmlTextBox report item to display HTML content, which supports a limited set of HTML tags and CSS attributes. Follow these steps:

Externally Convert to HTML

  1. Use an external MD -> HTML converter(e.g. Convert Markdown to HTML) to transform the MD content into HTML.
  2. Pass the converted HTML content to the HtmlTextBox report item in your Telerik report.
  3. Ensure that the HTML content uses only the supported HTML tags and CSS attributes.

Convert to HTML via User Functions

If the MD content cannot be converted to HTML beforehand, create a User Function that accepts the Markdown input and returns the corresponding HTML output. You may refer to the sample code below as a guideline.

To use the Markdown.ToHtml function, install the following NuGet package in the project with the user function - Markdig

namespace UserFunc
{
    public class Class1
    {
        public static string ConvertMarkdownToHtml(string markdown)
        {
            if (string.IsNullOrEmpty(markdown))
                return string.Empty;

            return Markdown.ToHtml(markdown);
        }

  • Input:
# Hello World

This is a **bold** statement, and this is *italic*.

## Features

- Item 1
- Item 2
- Item 3

Visit [Google](https://google.com) for more info.

> This is a blockquote.

---

Done!
  • Output:
<h1>Hello World</h1>
<p>This is a <strong>bold</strong> statement and this is <em>italic</em>.</p>
<h2>Features</h2>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<p>Visit <a href="https://google.com">Google</a> for more info.</p>
<blockquote>
<p>This is a blockquote.</p>
</blockquote>
<hr />
<p>Done!</p>

See Also

In this article