MarkdownConverter Class
Provides methods for parsing a Markdown string to a syntax tree and converting it to other formats.
public static class MarkdownConverterProperties
| Name | Description |
|---|---|
| Version | Gets or sets the version. |
Version
MarkdownConverter.csMethods
Convert(string, IMarkdownRenderer, MarkdownPipeline?, MarkdownParserContext?)
MarkdownConverter.csConverts a Markdown string using a custom IMarkdownRenderer.
public static object Convert(string markdown, IMarkdownRenderer renderer, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)Parameters
markdownstring- A Markdown text.
rendererIMarkdownRenderer- The renderer to convert Markdown to.
pipelineMarkdownPipeline?- The pipeline used for the conversion.
contextMarkdownParserContext?- A parser context used for the parsing.
Returns
Exceptions
ArgumentNullException- if markdown or writer variable are null
Normalize overloads
Normalize(string, NormalizeOptions?, MarkdownPipeline?, MarkdownParserContext?)
MarkdownConverter.csNormalizes the specified markdown to a normalized markdown text.
public static string Normalize(string markdown, NormalizeOptions? options = null, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)Parameters
markdownstring- The markdown.
optionsNormalizeOptions?- The normalize options
pipelineMarkdownPipeline?- The pipeline.
contextMarkdownParserContext?- A parser context used for the parsing.
Returns
string A normalized markdown text.
Normalize(string, TextWriter, NormalizeOptions?, MarkdownPipeline?, MarkdownParserContext?)
MarkdownConverter.csNormalizes 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
markdownstring- The markdown.
writerTextWriter- The destination
TextWriterthat will receive the result of the conversion. optionsNormalizeOptions?- The normalize options
pipelineMarkdownPipeline?- The pipeline.
contextMarkdownParserContext?- A parser context used for the parsing.
Returns
MarkdownDocument A normalized markdown text.
Parse overloads
Parse(string, MarkdownPipeline?, MarkdownParserContext?)
MarkdownConverter.csParses the specified markdown into an AST MarkdownDocument
public static MarkdownDocument Parse(string markdown, MarkdownPipeline? pipeline, MarkdownParserContext? context = null)Parameters
markdownstring- The markdown text.
pipelineMarkdownPipeline?- The pipeline used for the parsing.
contextMarkdownParserContext?- A parser context used for the parsing.
Returns
MarkdownDocument An AST Markdown document
Exceptions
ArgumentNullException- if markdown variable is null
Parse(string, bool)
MarkdownConverter.csParses the specified markdown into an AST MarkdownDocument
public static MarkdownDocument Parse(string markdown, bool trackTrivia = false)Parameters
markdownstring- The markdown text.
trackTriviabool- 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.csConverts a Markdown document to HTML.
public static string ToHtml(this MarkdownDocument document, MarkdownPipeline? pipeline = null)Parameters
documentMarkdownDocument- A Markdown document.
pipelineMarkdownPipeline?- The pipeline used for the conversion.
Returns
string The HTML string.
Exceptions
ArgumentNullException- If
documentis null.
ToHtml(MarkdownDocument, TextWriter, MarkdownPipeline?)
MarkdownConverter.csConverts a Markdown document to HTML.
public static void ToHtml(this MarkdownDocument document, TextWriter writer, MarkdownPipeline? pipeline = null)Parameters
documentMarkdownDocument- A Markdown document.
writerTextWriter- The destination
TextWriterthat will receive the result of the conversion. pipelineMarkdownPipeline?- The pipeline used for the conversion.
Exceptions
ArgumentNullException- If
documentis null.
ToHtml(string, MarkdownPipeline?, MarkdownParserContext?)
MarkdownConverter.csConverts a Markdown string to HTML.
public static string ToHtml(string markdown, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)Parameters
markdownstring- A Markdown text.
pipelineMarkdownPipeline?- The pipeline used for the conversion.
contextMarkdownParserContext?- A parser context used for the parsing.
Returns
string The HTML string.
Exceptions
ArgumentNullException- If
markdownis null.
ToHtml(string, TextWriter, MarkdownPipeline?, MarkdownParserContext?)
MarkdownConverter.csConverts 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
markdownstring- A Markdown text.
writerTextWriter- The destination
TextWriterthat will receive the result of the conversion. pipelineMarkdownPipeline?- The pipeline used for the conversion.
contextMarkdownParserContext?- 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.csConverts a Markdown string to Plain text by using a StringWriter .
public static string ToPlainText(string markdown, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)Parameters
markdownstring- A Markdown text.
pipelineMarkdownPipeline?- The pipeline used for the conversion.
contextMarkdownParserContext?- 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.csConverts 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
markdownstring- A Markdown text.
writerTextWriter- The destination
TextWriterthat will receive the result of the conversion. pipelineMarkdownPipeline?- The pipeline used for the conversion.
contextMarkdownParserContext?- 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