MarkdownConverter Class

Provides methods for parsing a Markdown string to a syntax tree and converting it to other formats.

public static class MarkdownConverter

Properties

NameDescription
VersionGets or sets the version.

Gets or sets the version.

public static string Version { get; }

Property value

string

Methods

NameDescription
Convert(string, IMarkdownRenderer, MarkdownPipeline?, MarkdownParserContext?)Converts a Markdown string using a custom IMarkdownRenderer.
Normalize(string, NormalizeOptions?, MarkdownPipeline?, MarkdownParserContext?)Normalizes the specified markdown to a normalized markdown text.
Normalize(string, TextWriter, NormalizeOptions?, MarkdownPipeline?, MarkdownParserContext?)Normalizes the specified markdown to a normalized markdown text.
Parse(string, MarkdownPipeline?, MarkdownParserContext?)Parses the specified markdown into an AST MarkdownDocument
Parse(string, bool)Parses the specified markdown into an AST MarkdownDocument
ToHtml(MarkdownDocument, MarkdownPipeline?)Converts a Markdown document to HTML.
ToHtml(MarkdownDocument, TextWriter, MarkdownPipeline?)Converts a Markdown document to HTML.
ToHtml(string, MarkdownPipeline?, MarkdownParserContext?)Converts a Markdown string to HTML.
ToHtml(string, TextWriter, MarkdownPipeline?, MarkdownParserContext?)Converts a Markdown string to HTML and output to the specified writer.
ToPlainText(string, MarkdownPipeline?, MarkdownParserContext?)Converts a Markdown string to Plain text by using a StringWriter .
ToPlainText(string, TextWriter, MarkdownPipeline?, MarkdownParserContext?)Converts a Markdown string to Plain text and output to the specified writer.

Convert(string, IMarkdownRenderer, MarkdownPipeline?, MarkdownParserContext?)

MarkdownConverter.cs

Converts a Markdown string using a custom IMarkdownRenderer.

public static object Convert(string markdown, IMarkdownRenderer renderer, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)

Parameters

markdown string
A Markdown text.
renderer IMarkdownRenderer
The renderer to convert Markdown to.
pipeline MarkdownPipeline?
The pipeline used for the conversion.
context MarkdownParserContext?
A parser context used for the parsing.

Returns

object

Exceptions

ArgumentNullException
if markdown or writer variable are null

Normalize overloads

Normalize(string, NormalizeOptions?, MarkdownPipeline?, MarkdownParserContext?)

MarkdownConverter.cs

Normalizes the specified markdown to a normalized markdown text.

public static string Normalize(string markdown, NormalizeOptions? options = null, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)
Parameters
markdown string
The markdown.
options NormalizeOptions?
The normalize options
pipeline MarkdownPipeline?
The pipeline.
context MarkdownParserContext?
A parser context used for the parsing.
Returns

string A normalized markdown text.

Normalize(string, TextWriter, NormalizeOptions?, MarkdownPipeline?, MarkdownParserContext?)

MarkdownConverter.cs

Normalizes the specified markdown to a normalized markdown text.

public static MarkdownDocument Normalize(string markdown, TextWriter writer, NormalizeOptions? options = null, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)
Parameters
markdown string
The markdown.
writer TextWriter
The destination TextWriter that will receive the result of the conversion.
options NormalizeOptions?
The normalize options
pipeline MarkdownPipeline?
The pipeline.
context MarkdownParserContext?
A parser context used for the parsing.
Returns

MarkdownDocument A normalized markdown text.

Parse overloads

Parse(string, MarkdownPipeline?, MarkdownParserContext?)

MarkdownConverter.cs

Parses the specified markdown into an AST MarkdownDocument

public static MarkdownDocument Parse(string markdown, MarkdownPipeline? pipeline, MarkdownParserContext? context = null)
Parameters
markdown string
The markdown text.
pipeline MarkdownPipeline?
The pipeline used for the parsing.
context MarkdownParserContext?
A parser context used for the parsing.
Returns

MarkdownDocument An AST Markdown document

Exceptions
ArgumentNullException
if markdown variable is null

Parse(string, bool)

MarkdownConverter.cs

Parses the specified markdown into an AST MarkdownDocument

public static MarkdownDocument Parse(string markdown, bool trackTrivia = false)
Parameters
markdown string
The markdown text.
trackTrivia bool
Whether to parse trivia such as whitespace, extra heading characters and unescaped string values.
Returns

MarkdownDocument An AST Markdown document

Exceptions
ArgumentNullException
if markdown variable is null

ToHtml overloads

ToHtml(MarkdownDocument, MarkdownPipeline?)

MarkdownConverter.cs

Converts a Markdown document to HTML.

public static string ToHtml(this MarkdownDocument document, MarkdownPipeline? pipeline = null)
Parameters
document MarkdownDocument
A Markdown document.
pipeline MarkdownPipeline?
The pipeline used for the conversion.
Returns

string The HTML string.

Exceptions
ArgumentNullException
If document is null.

ToHtml(MarkdownDocument, TextWriter, MarkdownPipeline?)

MarkdownConverter.cs

Converts a Markdown document to HTML.

public static void ToHtml(this MarkdownDocument document, TextWriter writer, MarkdownPipeline? pipeline = null)
Parameters
document MarkdownDocument
A Markdown document.
writer TextWriter
The destination TextWriter that will receive the result of the conversion.
pipeline MarkdownPipeline?
The pipeline used for the conversion.
Exceptions
ArgumentNullException
If document is null.

ToHtml(string, MarkdownPipeline?, MarkdownParserContext?)

MarkdownConverter.cs

Converts a Markdown string to HTML.

public static string ToHtml(string markdown, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)
Parameters
markdown string
A Markdown text.
pipeline MarkdownPipeline?
The pipeline used for the conversion.
context MarkdownParserContext?
A parser context used for the parsing.
Returns

string The HTML string.

Exceptions
ArgumentNullException
If markdown is null.

ToHtml(string, TextWriter, MarkdownPipeline?, MarkdownParserContext?)

MarkdownConverter.cs

Converts a Markdown string to HTML and output to the specified writer.

public static MarkdownDocument ToHtml(string markdown, TextWriter writer, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)
Parameters
markdown string
A Markdown text.
writer TextWriter
The destination TextWriter that will receive the result of the conversion.
pipeline MarkdownPipeline?
The pipeline used for the conversion.
context MarkdownParserContext?
A parser context used for the parsing.
Returns

MarkdownDocument The Markdown document that has been parsed

Exceptions
ArgumentNullException
if reader or writer variable are null

ToPlainText overloads

ToPlainText(string, MarkdownPipeline?, MarkdownParserContext?)

MarkdownConverter.cs

Converts a Markdown string to Plain text by using a StringWriter .

public static string ToPlainText(string markdown, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)
Parameters
markdown string
A Markdown text.
pipeline MarkdownPipeline?
The pipeline used for the conversion.
context MarkdownParserContext?
A parser context used for the parsing.
Returns

string The result of the conversion

Exceptions
ArgumentNullException
if markdown variable is null

ToPlainText(string, TextWriter, MarkdownPipeline?, MarkdownParserContext?)

MarkdownConverter.cs

Converts a Markdown string to Plain text and output to the specified writer.

public static MarkdownDocument ToPlainText(string markdown, TextWriter writer, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)
Parameters
markdown string
A Markdown text.
writer TextWriter
The destination TextWriter that will receive the result of the conversion.
pipeline MarkdownPipeline?
The pipeline used for the conversion.
context MarkdownParserContext?
A parser context used for the parsing.
Returns

MarkdownDocument The Markdown document that has been parsed

Exceptions
ArgumentNullException
if reader or writer variable are null