yavsc/Yavsc/wwwroot/js/to-markdown.min.js

1 line
9.7 KiB
JavaScript

7 years ago
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).toMarkdown=e()}}(function(){return function i(a,c,l){function u(n,e){if(!c[n]){if(!a[n]){var t="function"==typeof require&&require;if(!e&&t)return t(n,!0);if(f)return f(n,!0);var r=new Error("Cannot find module '"+n+"'");throw r.code="MODULE_NOT_FOUND",r}var o=c[n]={exports:{}};a[n][0].call(o.exports,function(e){var t=a[n][1][e];return u(t||e)},o,o.exports,i,a,c,l)}return c[n].exports}for(var f="function"==typeof require&&require,e=0;e<l.length;e++)u(l[e]);return u}({1:[function(e,t,n){"use strict";var a,c,l=e("./lib/md-converters"),u=e("./lib/gfm-converters"),f=e("./lib/html-parser"),d=e("collapse-whitespace"),r=["address","article","aside","audio","blockquote","body","canvas","center","dd","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frameset","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","isindex","li","main","menu","nav","noframes","noscript","ol","output","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"];function s(e){return-1!==r.indexOf(e.nodeName.toLowerCase())}var o=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"];function p(e){return-1!==o.indexOf(e.nodeName.toLowerCase())}function m(e){for(var t="",n=0;n<e.childNodes.length;n++)if(1===e.childNodes[n].nodeType)t+=e.childNodes[n]._replacement;else{if(3!==e.childNodes[n].nodeType)continue;t+=e.childNodes[n].data}return t}function h(e,t){if("string"==typeof t)return t===e.nodeName.toLowerCase();if(Array.isArray(t))return-1!==t.indexOf(e.nodeName.toLowerCase());if("function"==typeof t)return t.call(a,e);throw new TypeError("`filter` needs to be a string, array, or function")}function g(e,t){var n,r,o;return"left"===e?(n=t.previousSibling,r=/ $/):(n=t.nextSibling,r=/^ /),n&&(3===n.nodeType?o=r.test(n.nodeValue):1!==n.nodeType||s(n)||(o=r.test(n.textContent))),o}function v(e,t){var n="",r="";if(!s(e)){var o=/^[ \r\n\t]/.test(t),i=/[ \r\n\t]$/.test(t);o&&!g("left",e)&&(n=" "),i&&!g("right",e)&&(r=" ")}return{leading:n,trailing:r}}function N(e){var t,n=m(e);if(p(e)||/A|TH|TD/.test(e.nodeName)||!/^\s*$/i.test(n)){for(var r=0;r<c.length;r++){var o=c[r];if(h(e,o.filter)){if("function"!=typeof o.replacement)throw new TypeError("`replacement` needs to be a function that returns a string");var i=v(e,n);(i.leading||i.trailing)&&(n=n.trim()),t=i.leading+o.replacement.call(a,n,e)+i.trailing;break}}e._replacement=t}else e._replacement=""}(a=function(e,t){if(t=t||{},"string"!=typeof e)throw new TypeError(e+" is not a string");if(""===e)return"";e=e.replace(/(\d+)\. /g,"$1\\. ");var n,r,o=(n=e,r=(new f).parseFromString(n,"text/html"),d(r.documentElement,s),r).body,i=function(e){for(var t,n,r,o=[e],i=[];0<o.length;)for(t=o.shift(),i.push(t),n=t.childNodes,r=0;r<n.length;r++)1===n[r].nodeType&&o.push(n[r]);return i.shift(),i}(o);c=l.slice(0),t.gfm&&(c=u.concat(c)),t.converters&&(c=t.converters.concat(c));for(var a=i.length-1;0<=a;a--)N(i[a]);return m(o).replace(/^[\t\r\n]+|[\t\r\n\s]+$/g,"").replace(/\n\s+\n/g,"\n\n").replace(/\n{3,}/g,"\n\n")}).isBlock=s,a.isVoid=p,a.outer=function(e,t){return e.cloneNode(!1).outerHTML.replace("><",">"+t+"<")},t.exports=a},{"./lib/gfm-converters":2,"./lib/html-parser":3,"./lib/md-converters":4,"collapse-whitespace":7}],2:[function(e,t,n){"use strict";function c(e,t){var n=" ";return 0===Array.prototype.indexOf.call(t.parentNode.childNodes,t)&&(n="| "),n+e+" |"}var r=/highlight highlight-(\S+)/;t.exports=[{filter:"br",replacement:function(){return"\n"}},{filter:["del","s","strike"],replacement:function(e){return"~~"+e+"~~"}},{filter:function(e){return"checkbox"===e.type&&"LI"===e.parentNode.nodeName},replacement:function(e,t){return(t.checked?"[x]":"[ ]")+" "}},{filter:["th","td"],replacement:function(e,t){return c(e,t)}},{filter:"tr",replacement:function(e,t){var n