lib/odyssey/template.js
function md2json(tree) {
  var slide = null;
  var slides = [];
  var globalProperties = {}
  var elements = tree.slice(1);
  for (var i = 0; i < elements.length; ++i) {
    var el = elements[i];
    var add = true;
    if (el[0] === 'header' && el[1].level === 1) {
      if (slide) slides.push(Slide(slide.md_tree, slide.actions, slide.properties));
      slide = {
        md_tree: [],
        html: '',
        actions: [],
        properties: {}
      };
    } else if (el[0] === 'para') {
      // search inline code inside it
      var actions = [];
      for(var j = 1; j < el.length; ++j) {
        var subel = el[j];
        if (subel[0] === "inlinecode") {
          var lines = subel[1].split('\n');

          for (var ln = 0; ln < lines.length; ++ln) {
            var line = lines[ln];
            if (trim(line) !== '') {
              // if matches property, parse it
              if (prop_re.exec(line)) {
                var p = parseProperties(subel[1]);
                var prop = slide ? slide.properties: globalProperties
                for(var k in p) {
                  prop[k] = {
                    order: ln,
                    value: p[k]
                  }
                }
              } else {
                slide && slide.actions.push({
                  cmd: line,
                  order: ln
                });
              }
            }
          }

          // remove from list
          el.splice(j, 1);
          --j;
        }
      }
    }
    add && slide && slide.md_tree.push(el);
  }
  if (slide) slides.push(Slide(slide.md_tree, slide.actions, slide.properties));

  // remove the order for globalProperties
  slides.global = {};
  for(var k in globalProperties) {
    slides.global[k] = globalProperties[k].value;
  }

  return slides;
}
function md2json(tree) {
  var slide = null;
  var slides = [];
  var globalProperties = {}
  var elements = tree.slice(1);
  for (var i = 0; i < elements.length; ++i) {
    var el = elements[i];
    var add = true;
    if (el[0] === 'header' && el[1].level === 1) {
      if (slide) slides.push(Slide(slide.md_tree, slide.actions, slide.properties));
      slide = {
        md_tree: [],
        html: '',
        actions: [],
        properties: {}
      };
    } else if (el[0] === 'para') {
      // search inline code inside it
      var actions = [];
      for(var j = 1; j < el.length; ++j) {
        var subel = el[j];
        if (subel[0] === "inlinecode") {
          var lines = subel[1].split('\n');

          for (var ln = 0; ln < lines.length; ++ln) {
            var line = lines[ln];
            if (trim(line) !== '') {
              // if matches property, parse it
              if (prop_re.exec(line)) {
                var p = parseProperties(subel[1]);
                var prop = slide ? slide.properties: globalProperties
                for(var k in p) {
                  prop[k] = {
                    order: ln,
                    value: p[k]
                  }
                }
              } else {
                slide && slide.actions.push({
                  cmd: line,
                  order: ln
                });
              }
            }
          }

          // remove from list
          el.splice(j, 1);
          --j;
        }
      }
    }
    add && slide && slide.md_tree.push(el);
  }
  if (slide) slides.push(Slide(slide.md_tree, slide.actions, slide.properties));

  // remove the order for globalProperties
  slides.global = {};
  for(var k in globalProperties) {
    slides.global[k] = globalProperties[k].value;
  }

  return slides;
}
function md2json ( tree ) { var slide = null ; var slides = [ ] ; var globalProperties = { } var elements = tree . slice ( 1 ) ; for ( var i = 0 ; i < elements . length ; ++ i ) { var el = elements [ i ] ; var add = true ; if ( el [ 0 ] === 'header' && el [ 1 ] . level === 1 ) { if ( slide ) slides . push ( Slide ( slide . md_tree , slide . actions , slide . properties ) ) ; slide = { md_tree : [ ] , html : '' , actions : [ ] , properties : { } } ; } else if ( el [ 0 ] === 'para' ) { // search inline code inside it var actions = [ ] ; for ( var j = 1 ; j < el . length ; ++ j ) { var subel = el [ j ] ; if ( subel [ 0 ] === "inlinecode" ) { var lines = subel [ 1 ] . split ( '\n' ) ; for ( var ln = 0 ; ln < lines . length ; ++ ln ) { var line = lines [ ln ] ; if ( trim ( line ) !== '' ) { // if matches property, parse it if ( prop_re . exec ( line ) ) { var p = parseProperties ( subel [ 1 ] ) ; var prop = slide ? slide . properties : globalProperties for ( var k in p ) { prop [ k ] = { order : ln , value : p [ k ] } } } else { slide && slide . actions . push ( { cmd : line , order : ln } ) ; } } } // remove from list el . splice ( j , 1 ) ; -- j ; } } } add && slide && slide . md_tree . push ( el ) ; } if ( slide ) slides . push ( Slide ( slide . md_tree , slide . actions , slide . properties ) ) ; // remove the order for globalProperties slides . global = { } ; for ( var k in globalProperties ) { slides . global [ k ] = globalProperties [ k ] . value ; } return slides ; }
given a markdown parsed tree return a list of slides with
html and actions
given a markdown parsed tree return a list of slides with html and actions