Markdown = function(dialect) {
    switch (typeof dialect) {
    case "undefined":
      this.dialect = Markdown.dialects.Gruber;
      break;
    case "object":
      this.dialect = dialect;
      break;
    default:
      if ( dialect in Markdown.dialects )
        this.dialect = Markdown.dialects[dialect];
      else
        throw new Error("Unknown Markdown dialect '" + String(dialect) + "'");
      break;
    }
    this.em_state = [];
    this.strong_state = [];
    this.debug_indent = "";
  }
class Markdown

 Markdown processing in Javascript done right. We have very particular views
 on what constitutes 'right' which include:

 - produces well-formed HTML (this means that em and strong nesting is
   important)

 - has an intermediate representation to allow processing of parsed data (We
   in fact have two, both as [JsonML]: a markdown tree and an HTML tree).

 - is easily extensible to add new dialects without having to rewrite the
   entire parsing mechanics

 - has a good test suite

 This implementation fulfills all of these (except that the test suite could
 do with expanding to automatically run all the fixtures from other Markdown
 implementations.)

 ##### Intermediate Representation

 *TODO* Talk about this :) Its JsonML, but document the node names we use.

 [JsonML]: http://jsonml.org/ "JSON Markup Language"