(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.toMarkdown=f()}})(function(){var define,module,exports;return(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o0){elem=inqueue.shift() outqueue.push(elem) children=elem.childNodes for(i=0;i<','>'+content+'<')} function canConvert(node,filter){if(typeof filter==='string'){return filter===node.nodeName.toLowerCase()} if(Array.isArray(filter)){return filter.indexOf(node.nodeName.toLowerCase())!==-1}else if(typeof filter==='function'){return filter.call(toMarkdown,node)}else{throw new TypeError('`filter` needs to be a string, array, or function')}} function isFlankedByWhitespace(side,node){var sibling var regExp var isFlanked if(side==='left'){sibling=node.previousSibling regExp=/ $/}else{sibling=node.nextSibling regExp=/^ /} if(sibling){if(sibling.nodeType===3){isFlanked=regExp.test(sibling.nodeValue)}else if(sibling.nodeType===1&&!isBlock(sibling)){isFlanked=regExp.test(sibling.textContent)}} return isFlanked} function flankingWhitespace(node,content){var leading='' var trailing='' if(!isBlock(node)){var hasLeading=/^[ \r\n\t]/.test(content) var hasTrailing=/[ \r\n\t]$/.test(content) if(hasLeading&&!isFlankedByWhitespace('left',node)){leading=' '} if(hasTrailing&&!isFlankedByWhitespace('right',node)){trailing=' '}} return{leading:leading,trailing:trailing}} function process(node){var replacement var content=getContent(node) if(!isVoid(node)&&!/A|TH|TD/.test(node.nodeName)&&/^\s*$/i.test(content)){node._replacement='' return} for(var i=0;i=0;i--){process(nodes[i])} output=getContent(clone) return output.replace(/^[\t\r\n]+|[\t\r\n\s]+$/g,'').replace(/\n\s+\n/g,'\n\n').replace(/\n{3,}/g,'\n\n')} toMarkdown.isBlock=isBlock toMarkdown.isVoid=isVoid toMarkdown.outer=outer module.exports=toMarkdown},{"./lib/gfm-converters":2,"./lib/html-parser":3,"./lib/md-converters":4,"collapse-whitespace":7}],2:[function(require,module,exports){'use strict' function cell(content,node){var index=Array.prototype.indexOf.call(node.parentNode.childNodes,node) var prefix=' ' if(index===0)prefix='| ' return prefix+content+' |'} var highlightRegEx=/highlight highlight-(\S+)/module.exports=[{filter:'br',replacement:function(){return'\n'}},{filter:['del','s','strike'],replacement:function(content){return'~~'+content+'~~'}},{filter:function(node){return node.type==='checkbox'&&node.parentNode.nodeName==='LI'},replacement:function(content,node){return(node.checked?'[x]':'[ ]')+' '}},{filter:['th','td'],replacement:function(content,node){return cell(content,node)}},{filter:'tr',replacement:function(content,node){var borderCells='' var alignMap={left:':--',right:'--:',center:':-:'} if(node.parentNode.nodeName==='THEAD'){for(var i=0;i ') return'\n\n'+content+'\n\n'}},{filter:'li',replacement:function(content,node){content=content.replace(/^\s+/,'').replace(/\n/gm,'\n ') var prefix='* ' var parent=node.parentNode var index=Array.prototype.indexOf.call(parent.children,node)+1 prefix=/ol/i.test(parent.nodeName)?index+'. ':'* ' return prefix+content}},{filter:['ul','ol'],replacement:function(content,node){var strings=[] for(var i=0;i