MarkdownSharp when true, (most) bare plain URLs are auto-hyperlinked WARNING: this is a significant deviation from the markdown spec when true, RETURN becomes a literal newline WARNING: this is a significant deviation from the markdown spec use ">" for HTML output, or " />" for XHTML output when true, problematic URL characters like [, ], (, and so forth will be encoded WARNING: this is a significant deviation from the markdown spec when false, email addresses will never be auto-linked WARNING: this is a significant deviation from the markdown spec when true, bold and italic require non-word characters on either side WARNING: this is a significant deviation from the markdown spec Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML). maximum nested depth of [] and () supported by the transform; implementation detail Tabs are automatically converted to spaces as part of the transform this constant determines how "wide" those tabs become in spaces Create a new Markdown instance using default options Create a new Markdown instance and optionally load options from the supplied options parameter. Create a new Markdown instance and optionally load options from a configuration file. There they should be stored in the appSettings section, available options are: Markdown.StrictBoldItalic (true/false) Markdown.EmptyElementSuffix (">" or " />" without the quotes) Markdown.LinkEmails (true/false) Markdown.AutoNewLines (true/false) Markdown.AutoHyperlink (true/false) Markdown.EncodeProblemUrlCharacters (true/false) In the static constuctor we'll initialize what stays the same across all transforms. Transforms the provided Markdown-formatted text to HTML; see http://en.wikipedia.org/wiki/Markdown The order in which other subs are called here is essential. Link and image substitutions need to happen before EscapeSpecialChars(), so that any *'s or _'s in the a and img tags get encoded. Perform transformations that form block-level tags like paragraphs, headers, and list items. Perform transformations that occur *within* block-level tags like paragraphs, headers, and list items. splits on two or more newlines, to form "paragraphs"; each paragraph is then unhashed (if it is a hash) or wrapped in HTML p tag Reusable pattern to match balanced [brackets]. See Friedl's "Mastering Regular Expressions", 2nd Ed., pp. 328-331. Reusable pattern to match balanced (parens). See Friedl's "Mastering Regular Expressions", 2nd Ed., pp. 328-331. Strips link definitions from text, stores the URLs and titles in hash references. ^[id]: url "optional title" derived pretty much verbatim from PHP Markdown replaces any block-level HTML blocks with hash entries returns an array of HTML tokens comprising the input string. Each token is either a tag (possibly with nested, tags contained therein, such as <a href="<MTFoo>">, or a run of text between tags. Each element of the array is a two-element array; the first is either 'tag' or 'text'; the second is the actual value. Turn Markdown link shortcuts into HTML anchor tags [link text](url "title") [link text][id] [id] Turn Markdown image shortcuts into HTML img tags. ![alt text][id] ![alt text](url "optional title") Turn Markdown headers into HTML header tags Header 1 ======== Header 2 -------- # Header 1 ## Header 2 ## Header 2 with closing hashes ## ... ###### Header 6 Turn Markdown horizontal rules into HTML hr tags *** * * * --- - - - Turn Markdown lists into HTML ul and ol and li tags Process the contents of a single ordered or unordered list, splitting it into individual list items. /// Turn Markdown 4-space indented code into HTML pre code blocks Turn Markdown `code spans` into HTML code tags Turn Markdown *italics* and **bold** into HTML strong and em tags Turn markdown line breaks (two space at end of line) into HTML break tags Turn Markdown > quoted blocks into HTML blockquote blocks Turn angle-delimited URLs into HTML anchor tags <http://www.example.com> Remove one level of line-leading spaces encodes email address randomly roughly 10% raw, 45% hex, 45% dec note that @ is always encoded and : never is Encode/escape certain Markdown characters inside code blocks and spans where they are literals Encode any ampersands (that aren't part of an HTML entity) and left or right angle brackets Encodes any escaped characters such as \`, \*, \[ etc swap back in all the special characters we've hidden escapes Bold [ * ] and Italic [ _ ] characters hex-encodes some unusual "problem" chars in URLs to avoid URL detection problems Within tags -- meaning between < and > -- encode [\ ` * _] so they don't conflict with their use in Markdown for code, italics and strong. We're replacing each such character with its corresponding hash value; this is likely overkill, but it should prevent us from colliding with the escape values by accident. convert all tabs to _tabWidth spaces; standardizes line endings from DOS (CR LF) or Mac (CR) to UNIX (LF); makes sure text ends with a couple of newlines; removes any blank lines (only spaces) in the text this is to emulate what's evailable in PHP current version of MarkdownSharp; see http://code.google.com/p/markdownsharp/ for the latest code or to contribute Static constructor In the static constuctor we'll initialize what stays the same across all transforms. Strips link definitions from text, stores the URLs and titles in hash references. Link defs are in the form: ^[id]: url "optional title" Hashify HTML blocks These are all the transformations that form block-level tags like paragraphs, headers, and list items. These are all the transformations that occur *within* block-level tags like paragraphs, headers, and list items. Process the contents of a single ordered or unordered list, splitting it into individual list items. Encode/escape certain characters inside Markdown code runs. The point is that in code, these characters are literals, and lose their special Markdown meanings. Smart processing for ampersands and angle brackets that need to be encoded. Swap back in all the special characters we've hidden. Remove one level of line-leading tabs or spaces This is to emulate what's evailable in PHP Calculate an MD5 hash of an arbitrary string when true, (most) bare plain URLs are auto-hyperlinked WARNING: this is a significant deviation from the markdown spec when true, RETURN becomes a literal newline WARNING: this is a significant deviation from the markdown spec use ">" for HTML output, or " />" for XHTML output when true, problematic URL characters like [, ], (, and so forth will be encoded WARNING: this is a significant deviation from the markdown spec when false, email addresses will never be auto-linked WARNING: this is a significant deviation from the markdown spec when true, bold and italic require non-word characters on either side WARNING: this is a significant deviation from the markdown spec