This page covers smaller or more specialized extensions that are not part of UseAdvancedExtensions().
Enable with .UseBootstrap().
Adds Bootstrap CSS classes to generated HTML elements:
| Element | Class applied |
|---|---|
<table> |
table |
<blockquote> |
blockquote |
<figure> |
figure |
<figcaption> |
figure-caption |
<img> |
img-fluid |
var pipeline = new MarkdownPipelineBuilder()
.UseBootstrap()
.Build();
Enable with .UseSoftlineBreakAsHardlineBreak().
Makes every soft line break (a single newline inside a paragraph) render as a <br> tag instead of a space. Useful when you want each line to appear as written.
var pipeline = new MarkdownPipelineBuilder()
.UseSoftlineBreakAsHardlineBreak()
.Build();
Without this extension:
Line one
Line two
Renders as: <p>Line one Line two</p>
With this extension, it renders as: <p>Line one<br />Line two</p>
Enable with .UseJiraLinks(options).
Automatically converts JIRA-style project references (e.g., PROJECT-123) into clickable links.
using Markdig.Extensions.JiraLinks;
var pipeline = new MarkdownPipelineBuilder()
.UseJiraLinks(new JiraLinkOptions("https://jira.example.com/browse/"))
.Build();
var html = Markdown.ToHtml("Fixed in PROJ-456.", pipeline);
// => <p>Fixed in <a href="https://jira.example.com/browse/PROJ-456">PROJ-456</a>.</p>
Enable with .UseGlobalization().
Adds appropriate dir attributes on HTML elements for right-to-left content. Detects the text direction of each block and annotates it.
var pipeline = new MarkdownPipelineBuilder()
.UseGlobalization()
.Build();
Enable with .UseReferralLinks(rels).
Adds rel attributes to all rendered links:
var pipeline = new MarkdownPipelineBuilder()
.UseReferralLinks("nofollow", "noopener", "noreferrer")
.Build();
All links will have rel="nofollow noopener noreferrer" added.
Enable with .UseSelfPipeline().
Detects the pipeline configuration from the Markdown document itself via a special HTML comment tag:
<!--markdig:extensions=pipetables+footnotes-->
| A | B |
|---|---|
| 1 | 2 |
UseSelfPipeline cannot be combined with other extensions on the same builder — it replaces the pipeline entirely based on the document content.
var pipeline = new MarkdownPipelineBuilder()
.UseSelfPipeline() // Must be the only extension
.Build();
Enable with .UsePragmaLines().
Inserts <span id="pragma-line-N"></span> markers into the HTML output for each source line. This is useful for editor synchronization (scrolling an editor to the rendered position).
var pipeline = new MarkdownPipelineBuilder()
.UsePragmaLines()
.Build();
Enable with .UseNonAsciiNoEscape().
Disables percent-encoding of non-ASCII characters in URLs. This works around a rendering bug in Internet Explorer/Edge with local file links containing non-US-ASCII characters.
Only use this extension if you specifically need IE/Edge compatibility with non-ASCII file paths. It changes standard URL encoding behavior.
var pipeline = new MarkdownPipelineBuilder()
.UseNonAsciiNoEscape()
.Build();
Enable with .UsePreciseSourceLocation().
Maps every AST node to its exact position in the original source text via the Span property. Useful for syntax highlighting, editors, and linters.
var pipeline = new MarkdownPipelineBuilder()
.UsePreciseSourceLocation()
.Build();
var document = Markdown.Parse(text, pipeline);
foreach (var node in document.Descendants())
{
Console.WriteLine($"{node.GetType().Name}: {node.Span}");
}
Use .DisableHtml() (a configuration option, not an extension).
Removes the HTML block parser and disables inline HTML parsing. This prevents raw HTML injection, but it is not a complete security solution on its own:
var pipeline = new MarkdownPipelineBuilder()
.DisableHtml()
.Build();
Markdig does not sanitize the generated HTML. If you render untrusted Markdown in a browser, you should still sanitize the output HTML (and consider filtering/rewriting link and image URLs) to prevent XSS.