Markdown To Html C#



Markdown

  1. Markdown To Html C# Nuget
  2. Html To Markdown Converter C#

Md2html - Markdown 2 HTML Command Line Tool - Google Project Hosting. It will be based on Markdown Sharp, and will be written in C# 3.0 for. You have probably heard about Markdown, a simple markup language alternative to HTML. Or plain text, depend on how you use it. Markdown stands in the middle between HTML and plain text.

Markdown is a system for writing web pages by marking up the text much as you would in an email rather than writing html code. The marked-up text gets converted to html, replacing the marks with the proper html code.

For now, let’s delete all of the stuff that’s there and write a bit of markdown.

You make things bold using two asterisks, like this: **bold**, and you make things italics by using underscores, like this: _italics_.

Markdown To Html C#

You can make a bulleted list by writing a list with hyphens or asterisks, like this:

or like this:

Each will appear as:

  • bold with double-asterisks
  • italics with underscores
  • code-type font with backticks

(I prefer hyphens over asterisks, myself.)

You can make a numbered list by just using numbers. You can use the same number over and over if you want:

This will appear as:

  1. bold with double-asterisks
  2. italics with underscores
  3. code-type font with backticks

You can make section headers of different sizes by initiating a line with some number of # symbols:

You compile the R Markdown document to an html webpage by clicking the “Knit HTML” in the upper-left. And note the little question mark next to it; click the question mark and you’ll get a “Markdown Quick Reference” (with the Markdown syntax) as well to the RStudio documentation on R Markdown.

Goals

MarkdownDeep was designed with the following goals in mind:

  • To provide an extremely effecient server side implemenation of Markdown.
  • To provide an 100% compatibile Javascript implementation.
  • To provide customization of the generated output markdown.
  • To provide built in XSS attack prevention.

The Markdown to HTML Transformation Process

MarkdownDeep takes a different approach to most other Markdown processors. Instead of using a series of Regular Expression replacements, MarkdownDeep builds a document heirarchy which it then renders.

Block processing is the process of parsing the input document into a heirarchial tree representing the structure of the document.

  1. The input text is loaded into a StringScanner which is then passed to a BlockProcessor.
  2. The BlockProcessor evaluates the input text creating a Block for each line.
  3. Sequences of line blocks are then assessed and related lines are merged to form the actual block structure of the document. (eg: consecutive indent blocks are folded into code blocks, consecutive list items into lists etc...).
  4. Nested structures (eg: blockquotes inside blockquotes) are also handled by the BlockProcessor by creating a new input string containing the nested input and recusively passing that through a another BlockProcessor instance.

Once the block structure of the document has been parsed, those blocks are recursively rendered to a StringBuilder to produce the final output. As part of the rendering process, spans of text are formatted using a SpanFormatter:

  1. Each span of text is tokenized into a series of Tokens representing the internal content of the text span.
  2. Balanced tokens such as emphasis and strong are matched against each other.
  3. Tokens are rendered to a StringBuilder to produce the final output.

This approach has its pros and cons:

Html
  • The C# implementation is significantly faster as the input text is scanned far fewer times.
  • The code base is larger, but can also be debugged and extended more easily.
  • The performance of the Javascript implementation depends heavily on the browser. For Chrome, Firefox and Safari it performs as well if not better than other regular expression based Javascript implementations. For Internet Explorer, it performs considerably worse - but still acceptible for typical use. Initial testing in IE9 Technology Preview shows performance comparable to the other browsers.

Ambiguous Markdown Input

There are cases where Markdown input can be interpreted in multiple ways. In these cases MarkdownDeep favours performance, code maintainability and correct mark-up in preference to compatibility with other implementations and and may generate different output.

For example, when dealing with nested emphasis and bold indicators such as this:

many implementations of Markdown will generate this:

whereas MarkdownDeep will produce the more correct:

In all cases where the Markdown syntax is unambiguous, MarkdownDeep generates equivalent output.

Whitespace in Output

MarkdownDeep makes no effort to generate output that matches the whitespace output of other implementations, nor does it maintain the whitespace of the input text except where that whitespace affects the finally rendered page (eg: code blocks).

At some point an option may be added to do pretty formatted (indented) output.

Markdown To Html C# Nuget

Use of HTML Entities

Html To Markdown Converter C#

MarkdownDeep makes no promises on the use of HTML entities in it's output and may generate different (but equivalent) output to other Markdown processors. For example: MarkdownDeep transforms > into > where as some other Markdown processors do not.