All files Document.js

40% Statements 4/10
100% Branches 0/0
0% Functions 0/2
40% Lines 4/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32  1x 1x     1x                                 1x                  
// Import
var re = require('./regex')
var Table = require('./Table')
 
// Export
module.exports = Document
 
/**
 * Markdown document parser and editor
 *
 * @param {String} src Markdown source
 */
function Document (rawSrc) {
  this.tables = Document.parse(rawSrc)
}
 
/**
 * Find all markdown tables in a source and return an array of Table
 *
 * @param  {String} src Markdown source
 * @return {Array}     Array of markdown table objects
 */
Document.parse = function (src) {
  var reTable = new RegExp('^(' + re.wholeTable + ')(\n|\\Z)', 'mg')
  var result
  var tables = []
  while ((result = reTable.exec(src)) !== null) {
    tables.push(new Table(result[0], result.index))
  }
  return tables
}