lib/stmd.js
function(block, in_tight_list) {
  var tag;
  var attr;
  var info_words;
  switch (block.t) {
    case 'Document':
      var whole_doc = this.renderBlocks(block.children);
      return (whole_doc === '' ? '' : whole_doc + '\n');
    case 'Paragraph':
      if (in_tight_list) {
        return this.renderInlines(block.inline_content);
      } else {
        return inTags('p', [], this.renderInlines(block.inline_content));
      }
      break;
    case 'BlockQuote':
      var filling = this.renderBlocks(block.children);
      return inTags('blockquote', [], filling === '' ? this.innersep :
          this.innersep + this.renderBlocks(block.children) + this.innersep);
    case 'ListItem':
      return inTags('li', [], this.renderBlocks(block.children, in_tight_list).trim());
    case 'List':
      tag = block.list_data.type == 'Bullet' ? 'ul' : 'ol';
      attr = (!block.list_data.start || block.list_data.start == 1) ?
              [] : [['start', block.list_data.start.toString()]];
      return inTags(tag, attr, this.innersep +
                    this.renderBlocks(block.children, block.tight) +
                    this.innersep);
    case 'ATXHeader':
    case 'SetextHeader':
      tag = 'h' + block.level;
      return inTags(tag, [], this.renderInlines(block.inline_content));
    case 'IndentedCode':
      return inTags('pre', [],
              inTags('code', [], this.escape(block.string_content)));
    case 'FencedCode':
      info_words = block.info.split(/ +/);
      attr = info_words.length === 0 || info_words[0].length === 0 ?
                   [] : [['class','language-' +
                                   this.escape(info_words[0],true)]];
      return inTags('pre', [],
              inTags('code', attr, this.escape(block.string_content)));
    case 'HtmlBlock':
      return block.string_content;
    case 'ReferenceDef':
      return "";
    case 'HorizontalRule':
      return inTags('hr',[],"",true);
    default:
      console.log("Uknown block type " + block.t);
      return "";
  }
}
function(block, in_tight_list) {
  var tag;
  var attr;
  var info_words;
  switch (block.t) {
    case 'Document':
      var whole_doc = this.renderBlocks(block.children);
      return (whole_doc === '' ? '' : whole_doc + '\n');
    case 'Paragraph':
      if (in_tight_list) {
        return this.renderInlines(block.inline_content);
      } else {
        return inTags('p', [], this.renderInlines(block.inline_content));
      }
      break;
    case 'BlockQuote':
      var filling = this.renderBlocks(block.children);
      return inTags('blockquote', [], filling === '' ? this.innersep :
          this.innersep + this.renderBlocks(block.children) + this.innersep);
    case 'ListItem':
      return inTags('li', [], this.renderBlocks(block.children, in_tight_list).trim());
    case 'List':
      tag = block.list_data.type == 'Bullet' ? 'ul' : 'ol';
      attr = (!block.list_data.start || block.list_data.start == 1) ?
              [] : [['start', block.list_data.start.toString()]];
      return inTags(tag, attr, this.innersep +
                    this.renderBlocks(block.children, block.tight) +
                    this.innersep);
    case 'ATXHeader':
    case 'SetextHeader':
      tag = 'h' + block.level;
      return inTags(tag, [], this.renderInlines(block.inline_content));
    case 'IndentedCode':
      return inTags('pre', [],
              inTags('code', [], this.escape(block.string_content)));
    case 'FencedCode':
      info_words = block.info.split(/ +/);
      attr = info_words.length === 0 || info_words[0].length === 0 ?
                   [] : [['class','language-' +
                                   this.escape(info_words[0],true)]];
      return inTags('pre', [],
              inTags('code', attr, this.escape(block.string_content)));
    case 'HtmlBlock':
      return block.string_content;
    case 'ReferenceDef':
      return "";
    case 'HorizontalRule':
      return inTags('hr',[],"",true);
    default:
      console.log("Uknown block type " + block.t);
      return "";
  }
}
function ( block , in_tight_list ) { var tag ; var attr ; var info_words ; switch ( block . t ) { case 'Document' : var whole_doc = this . renderBlocks ( block . children ) ; return ( whole_doc === '' ? '' : whole_doc + '\n' ) ; case 'Paragraph' : if ( in_tight_list ) { return this . renderInlines ( block . inline_content ) ; } else { return inTags ( 'p' , [ ] , this . renderInlines ( block . inline_content ) ) ; } break ; case 'BlockQuote' : var filling = this . renderBlocks ( block . children ) ; return inTags ( 'blockquote' , [ ] , filling === '' ? this . innersep : this . innersep + this . renderBlocks ( block . children ) + this . innersep ) ; case 'ListItem' : return inTags ( 'li' , [ ] , this . renderBlocks ( block . children , in_tight_list ) . trim ( ) ) ; case 'List' : tag = block . list_data . type == 'Bullet' ? 'ul' : 'ol' ; attr = ( ! block . list_data . start || block . list_data . start == 1 ) ? [ ] : [ [ 'start' , block . list_data . start . toString ( ) ] ] ; return inTags ( tag , attr , this . innersep + this . renderBlocks ( block . children , block . tight ) + this . innersep ) ; case 'ATXHeader' : case 'SetextHeader' : tag = 'h' + block . level ; return inTags ( tag , [ ] , this . renderInlines ( block . inline_content ) ) ; case 'IndentedCode' : return inTags ( 'pre' , [ ] , inTags ( 'code' , [ ] , this . escape ( block . string_content ) ) ) ; case 'FencedCode' : info_words = block . info . split ( /  + / ) ; attr = info_words . length === 0 || info_words [ 0 ] . length === 0 ? [ ] : [ [ 'class' , 'language-' + this . escape ( info_words [ 0 ] , true ) ] ] ; return inTags ( 'pre' , [ ] , inTags ( 'code' , attr , this . escape ( block . string_content ) ) ) ; case 'HtmlBlock' : return block . string_content ; case 'ReferenceDef' : return "" ; case 'HorizontalRule' : return inTags ( 'hr' , [ ] , "" , true ) ; default : console . log ( "Uknown block type " + block . t ) ; return "" ; } }
Render a single block element.
Render a single block element .