text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).SimpleMarkdown=e()}(this,function(){"use strict";function r(t){return t.replace(k,"\n").replace(x,"").replace(w,"    ")}function c(t,e){var n=t||{};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function t(m,n){var y,g=Object.keys(m).filter(function(t){var e=m[t];if(null==e||null==e.match)return!1;var n=e.order;return"number"==typeof n&&isFinite(n)||"undefined"==typeof console||console.warn("simple-markdown: Invalid order for rule `"+t+"`: "+String(n)),!0});g.sort(function(t,e){var n=m[t],r=m[e],o=n.order,u=r.order;if(o!==u)return o-u;var a=n.quality?0:1,l=r.quality?0:1;return a!=l?a-l:t<e?-1:e<t?1:0});var v=function(t,e){var n=[];for(y=e=e||y;t;){var r=null,o=null,u=null,a=NaN,l=0,c=g[0],i=m[c];do{var f=i.order,p=null==e.prevCapture?"":e.prevCapture[0],s=i.match(t,e,p);if(s){var d=i.quality?i.quality(s,e,p):0;d<=a||(r=c,o=i,u=s,a=d)}c=g[++l],i=m[c]}while(i&&(!u||i.order===f&&i.quality));if(null==o||null==u)throw new Error("Could not find a matching rule for the below content. The rule with highest `order` should always match content provided to it. Check the definition of `match` for '"+g[g.length-1]+"'. It seems to not match the following source:\n"+t);if(u.index)throw new Error("`match` must return a capture starting at index 0 (the current parse index). Did you forget a ^ at the start of the RegExp?");var h=o.parse(u,v,e);Array.isArray(h)?Array.prototype.push.apply(n,h):(null==h.type&&(h.type=r),n.push(h)),e.prevCapture=u,t=t.substring(e.prevCapture[0].length)}return n};return function(t,e){return(y=c(e,n)).inline||y.disableAutoBlockNewlines||(t+="\n\n"),y.prevCapture=null,v(r(t),y)}}function e(n){function t(t,e){return e.inline?n.exec(t):null}return t.regex=n,t}function n(n){function t(t,e){return e.inline?null:n.exec(t)}return t.regex=n,t}function o(n){function t(t,e){return n.exec(t)}return t.regex=n,t}function a(t,e,n){return{$$typeof:b,type:t,key:null==e?void 0:e,ref:null,props:n,_owner:null}}function i(t,e,n,r){n=n||{},r=void 0===r||r;var o="";for(var u in n){var a=n[u];Object.prototype.hasOwnProperty.call(n,u)&&a&&(o+=" "+d(u)+'="'+d(a)+'"')}var l="<"+t+o+">";return r?l+e+"</"+t+">":l}function u(t){if(null==t)return null;try{var e=decodeURIComponent(t).replace(/[^A-Za-z0-9/:]/g,"").toLowerCase();if(0===e.indexOf("javascript:")||0===e.indexOf("vbscript:")||0===e.indexOf("data:"))return null}catch(t){return null}return t}function l(t){return t.replace(A,"$1")}function f(t,e,n){var r=n.inline||!1;n.inline=!0;var o=t(e,n);return n.inline=r,o}function p(t,e,n){return{content:f(e,t[1],n)}}function s(){return{}}function d(t){return String(t).replace(E,function(t){return S[t]})}var h,m,y,g,v,k=/\r\n?/g,w=/\t/g,x=/\f/g,b="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,_={},E=/[<>&"']/g,S={"<":"&lt;",">":"&gt;","&":"&amp;",'"':"&quot;","'":"&#x27;","/":"&#x2F;","`":"&#96;"},A=/\\([^0-9A-Za-z\s])/g,R="(?:[*+-]|\\d+\\.)",$="( *)("+R+") +",O=new RegExp("^"+$),T=new RegExp($+"[^\\n]*(?:\\n(?!\\1"+R+" )[^\\n]*)*(\n|$)","gm"),j=/\n{2,}$/,C=/^ (?= *`)|(` *) $/g,P=j,q=/ *\n+$/,F=new RegExp("^( *)("+R+") [\\s\\S]+?(?:\n{2,}(?! )(?!\\1"+R+" )\\n*|\\s*\n*$)"),B=/(?:^|\n)( *)$/,N=(h=/^ *\| *| *\| *$/g,m=/ *$/,y=/^ *-+: *$/,g=/^ *:-+: *$/,v=/^ *:-+ *$/,{parseTable:z(!0),parseNpTable:z(!1),TABLE_REGEX:/^ *(\|.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/,NPTABLE_REGEX:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/});function I(t){return y.test(t)?"right":g.test(t)?"center":v.test(t)?"left":null}function L(t,e,n,r){var o=n.inTable;n.inTable=!0;var u=e(t.trim(),n);n.inTable=o;var a=[[]];return u.forEach(function(t,e){"tableSeparator"===t.type?r&&(0===e||e===u.length-1)||a.push([]):("text"!==t.type||null!=u[e+1]&&"tableSeparator"!==u[e+1].type||(t.content=t.content.replace(m,"")),a[a.length-1].push(t))}),a}function z(p){return function(t,e,n){n.inline=!0;var r,o,u,a,l,c=L(t[1],e,n,p),i=(l=t[2],p&&(l=l.replace(h,"")),l.trim().split("|").map(I)),f=(r=t[3],o=e,u=n,a=p,r.trim().split("\n").map(function(t){return L(t,o,u,a)}));return n.inline=!1,{type:"table",header:c,align:i,cells:f}}}function G(t,e,n){var r=(t[2]||t[1]).replace(/\s+/g," ").toLowerCase();if(e._defs&&e._defs[r]){var o=e._defs[r];n.target=o.target,n.title=o.title}return e._refs=e._refs||{},e._refs[r]=e._refs[r]||[],e._refs[r].push(n),n}function X(n,r,o){if(!r)throw new Error("simple-markdown: outputFor: `property` must be defined. if you just upgraded, you probably need to replace `outputFor` with `reactFor`");var u,t=(n.Array||K.Array)[r];if(!t)throw new Error("simple-markdown: outputFor: to join nodes of type `"+r+"` you must provide an `Array:` joiner rule with that type, Please see the docs for details on specifying an Array rule.");var a=t,l=function(t,e){return u=e=e||u,Array.isArray(t)?a(t,l,e):n[t.type][r](t,l,e)};return function(t,e){return u=c(e,o),l(t,u)}}function Z(t,e){return(e=e||{}).inline=!1,V(t,e)}function U(t,e){var n=j.test(t);return(e=e||{}).inline=!n,V(t,e)}function H(t,e){return W(Z(t,e),e)}var M="(?:\\[[^\\]]*\\]|[^\\[\\]]|\\](?=[^\\[]*\\]))*",D="\\s*<?((?:\\([^)]*\\)|[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*",Q=/mailto:/i,J=0,K={Array:{react:function(t,e,n){for(var r=n.key,o=[],u=0;u<t.length;u++){n.key=""+u;var a=t[u];if("text"===a.type)for(a={type:"text",content:a.content};u+1<t.length&&"text"===t[u+1].type;u++)a.content+=t[u+1].content;o.push(e(a,n))}return n.key=r,o},html:function(t,e,n){for(var r="",o=0;o<t.length;o++){var u=t[o];if("text"===u.type)for(u={type:"text",content:u.content};o+1<t.length&&"text"===t[o+1].type;o++)u.content+=t[o+1].content;r+=e(u,n)}return r}},heading:{order:J++,match:n(/^ *(#{1,6})([^\n]+?)#* *(?:\n *)+\n/),parse:function(t,e,n){return{level:t[1].length,content:f(e,t[2].trim(),n)}},react:function(t,e,n){return a("h"+t.level,n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("h"+t.level,e(t.content,n))}},nptable:{order:J++,match:n(N.NPTABLE_REGEX),parse:N.parseNpTable,react:null,html:null},lheading:{order:J++,match:n(/^([^\n]+)\n *(=|-){3,} *(?:\n *)+\n/),parse:function(t,e,n){return{type:"heading",level:"="===t[2]?1:2,content:f(e,t[1],n)}},react:null,html:null},hr:{order:J++,match:n(/^( *[-*_]){3,} *(?:\n *)+\n/),parse:s,react:function(t,e,n){return a("hr",n.key,_)},html:function(t,e,n){return"<hr>"}},codeBlock:{order:J++,match:n(/^(?:    [^\n]+\n*)+(?:\n *)+\n/),parse:function(t,e,n){return{lang:void 0,content:t[0].replace(/^    /gm,"").replace(/\n+$/,"")}},react:function(t,e,n){var r=t.lang?"markdown-code-"+t.lang:void 0;return a("pre",n.key,{children:a("code",null,{className:r,children:t.content})})},html:function(t,e,n){var r=t.lang?"markdown-code-"+t.lang:void 0,o=i("code",d(t.content),{class:r});return i("pre",o)}},fence:{order:J++,match:n(/^ *(`{3,}|~{3,}) *(?:(\S+) *)?\n([\s\S]+?)\n?\1 *(?:\n *)+\n/),parse:function(t,e,n){return{type:"codeBlock",lang:t[2]||void 0,content:t[3]}},react:null,html:null},blockQuote:{order:J++,match:n(/^( *>[^\n]+(\n[^\n]+)*\n*)+\n{2,}/),parse:function(t,e,n){return{content:e(t[0].replace(/^ *> ?/gm,""),n)}},react:function(t,e,n){return a("blockquote",n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("blockquote",e(t.content,n))}},list:{order:J++,match:function(t,e){var n=null==e.prevCapture?"":e.prevCapture[0],r=B.exec(n),o=e._list||!e.inline;return r&&o?(t=r[1]+t,F.exec(t)):null},parse:function(t,s,d){var e=t[2],n=1<e.length,r=n?+e:void 0,h=t[0].replace(P,"\n").match(T),m=!1;return{ordered:n,start:r,items:h.map(function(t,e){var n=O.exec(t),r=n?n[0].length:0,o=new RegExp("^ {1,"+r+"}","gm"),u=t.replace(o,"").replace(O,""),a=e===h.length-1,l=-1!==u.indexOf("\n\n")||a&&m;m=l;var c,i=d.inline,f=d._list;d._list=!0,c=l?(d.inline=!1,u.replace(q,"\n\n")):(d.inline=!0,u.replace(q,""));var p=s(c,d);return d.inline=i,d._list=f,p})}},react:function(t,n,r){return a(t.ordered?"ol":"ul",r.key,{start:t.start,children:t.items.map(function(t,e){return a("li",""+e,{children:n(t,r)})})})},html:function(t,e,n){var r=t.items.map(function(t){return i("li",e(t,n))}).join("");return i(t.ordered?"ol":"ul",r,{start:t.start})}},def:{order:J++,match:n(/^ *\[([^\]]+)\]: *<?([^\s>]*)>?(?: +["(]([^\n]+)[")])? *\n(?: *\n)*/),parse:function(t,e,n){var r=t[1].replace(/\s+/g," ").toLowerCase(),o=t[2],u=t[3];return n._refs&&n._refs[r]&&n._refs[r].forEach(function(t){t.target=o,t.title=u}),n._defs=n._defs||{},n._defs[r]={target:o,title:u},{def:r,target:o,title:u}},react:function(){return null},html:function(){return""}},table:{order:J++,match:n(N.TABLE_REGEX),parse:N.parseTable,react:function(e,n,r){function o(t){return null==e.align[t]?{}:{textAlign:e.align[t]}}var t=e.header.map(function(t,e){return a("th",""+e,{style:o(e),scope:"col",children:n(t,r)})}),u=e.cells.map(function(t,e){return a("tr",""+e,{children:t.map(function(t,e){return a("td",""+e,{style:o(e),children:n(t,r)})})})});return a("table",r.key,{children:[a("thead","thead",{children:a("tr",null,{children:t})}),a("tbody","tbody",{children:u})]})},html:function(e,n,r){function o(t){return null==e.align[t]?"":"text-align:"+e.align[t]+";"}var t=e.header.map(function(t,e){return i("th",n(t,r),{style:o(e),scope:"col"})}).join(""),u=e.cells.map(function(t){var e=t.map(function(t,e){return i("td",n(t,r),{style:o(e)})}).join("");return i("tr",e)}).join(""),a=i("thead",i("tr",t)),l=i("tbody",u);return i("table",a+l)}},newline:{order:J++,match:n(/^(?:\n *)*\n/),parse:s,react:function(t,e,n){return"\n"},html:function(t,e,n){return"\n"}},paragraph:{order:J++,match:n(/^((?:[^\n]|\n(?! *\n))+)(?:\n *)+\n/),parse:p,react:function(t,e,n){return a("div",n.key,{className:"paragraph",children:e(t.content,n)})},html:function(t,e,n){return i("div",e(t.content,n),{class:"paragraph"})}},escape:{order:J++,match:e(/^\\([^0-9A-Za-z\s])/),parse:function(t,e,n){return{type:"text",content:t[1]}},react:null,html:null},tableSeparator:{order:J++,match:function(t,e){return e.inTable?/^ *\| */.exec(t):null},parse:function(){return{type:"tableSeparator"}},react:function(){return" | "},html:function(){return" &vert; "}},autolink:{order:J++,match:e(/^<([^: >]+:\/[^ >]+)>/),parse:function(t,e,n){return{type:"link",content:[{type:"text",content:t[1]}],target:t[1]}},react:null,html:null},mailto:{order:J++,match:e(/^<([^ >]+@[^ >]+)>/),parse:function(t,e,n){var r=t[1],o=t[1];return Q.test(o)||(o="mailto:"+o),{type:"link",content:[{type:"text",content:r}],target:o}},react:null,html:null},url:{order:J++,match:e(/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/),parse:function(t,e,n){return{type:"link",content:[{type:"text",content:t[1]}],target:t[1],title:void 0}},react:null,html:null},link:{order:J++,match:e(new RegExp("^\\[("+M+")\\]\\("+D+"\\)")),parse:function(t,e,n){return{content:e(t[1],n),target:l(t[2]),title:t[3]}},react:function(t,e,n){return a("a",n.key,{href:u(t.target),title:t.title,children:e(t.content,n)})},html:function(t,e,n){var r={href:u(t.target),title:t.title};return i("a",e(t.content,n),r)}},image:{order:J++,match:e(new RegExp("^!\\[("+M+")\\]\\("+D+"\\)")),parse:function(t,e,n){return{alt:t[1],target:l(t[2]),title:t[3]}},react:function(t,e,n){return a("img",n.key,{src:u(t.target),alt:t.alt,title:t.title})},html:function(t,e,n){return i("img","",{src:u(t.target),alt:t.alt,title:t.title},!1)}},reflink:{order:J++,match:e(new RegExp("^\\[("+M+")\\]\\s*\\[([^\\]]*)\\]")),parse:function(t,e,n){return G(t,n,{type:"link",content:e(t[1],n)})},react:null,html:null},refimage:{order:J++,match:e(new RegExp("^!\\[("+M+")\\]\\s*\\[([^\\]]*)\\]")),parse:function(t,e,n){return G(t,n,{type:"image",alt:t[1]})},react:null,html:null},em:{order:J,match:e(new RegExp("^\\b_((?:__|\\\\[\\s\\S]|[^\\\\_])+?)_\\b|^\\*(?=\\S)((?:\\*\\*|\\\\[\\s\\S]|\\s+(?:\\\\[\\s\\S]|[^\\s\\*\\\\]|\\*\\*)|[^\\s\\*\\\\])+?)\\*(?!\\*)")),quality:function(t){return t[0].length+.2},parse:function(t,e,n){return{content:e(t[2]||t[1],n)}},react:function(t,e,n){return a("em",n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("em",e(t.content,n))}},strong:{order:J,match:e(/^\*\*((?:\\[\s\S]|[^\\])+?)\*\*(?!\*)/),quality:function(t){return t[0].length+.1},parse:p,react:function(t,e,n){return a("strong",n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("strong",e(t.content,n))}},u:{order:J++,match:e(/^__((?:\\[\s\S]|[^\\])+?)__(?!_)/),quality:function(t){return t[0].length},parse:p,react:function(t,e,n){return a("u",n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("u",e(t.content,n))}},del:{order:J++,match:e(/^~~(?=\S)((?:\\[\s\S]|~(?!~)|[^\s~\\]|\s(?!~~))+?)~~/),parse:p,react:function(t,e,n){return a("del",n.key,{children:e(t.content,n)})},html:function(t,e,n){return i("del",e(t.content,n))}},inlineCode:{order:J++,match:e(/^(`+)([\s\S]*?[^`])\1(?!`)/),parse:function(t,e,n){return{content:t[2].replace(C,"$1")}},react:function(t,e,n){return a("code",n.key,{children:t.content})},html:function(t,e,n){return i("code",d(t.content))}},br:{order:J++,match:o(/^ {2,}\n/),parse:s,react:function(t,e,n){return a("br",n.key,_)},html:function(t,e,n){return"<br>"}},text:{order:J++,match:o(/^[\s\S]+?(?=[^0-9A-Za-z\s\u00c0-\uffff]|\n\n| {2,}\n|\w+:\S|$)/),parse:function(t,e,n){return{content:t[0]}},react:function(t,e,n){return t.content},html:function(t,e,n){return d(t.content)}}},V=t(K),W=X(K,"react"),Y=X(K,"html");return{defaultRules:K,parserFor:t,outputFor:X,inlineRegex:e,blockRegex:n,anyScopeRegex:o,parseInline:f,parseBlock:function(t,e,n){var r=n.inline||!1;n.inline=!1;var o=t(e+"\n\n",n);return n.inline=r,o},markdownToReact:H,markdownToHtml:function(t,e){return Y(Z(t,e),e)},ReactMarkdown:function(t){var e={};for(var n in t)"source"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.children=H(t.source),a("div",null,e)},defaultBlockParse:Z,defaultInlineParse:function(t,e){return(e=e||{}).inline=!0,V(t,e)},defaultImplicitParse:U,defaultReactOutput:W,defaultHtmlOutput:Y,preprocess:r,sanitizeText:d,sanitizeUrl:u,unescapeUrl:l,htmlTag:i,reactElement:a,defaultRawParse:V,ruleOutput:function(r,o){return o||"undefined"==typeof console||console.warn("simple-markdown ruleOutput should take 'react' or 'html' as the second argument."),function(t,e,n){return r[t.type][o](t,e,n)}},reactFor:function(l){var c=function(t,e){if(e=e||{},Array.isArray(t)){for(var n=e.key,r=[],o=null,u=0;u<t.length;u++){e.key=""+u;var a=c(t[u],e);"string"==typeof a&&"string"==typeof o?(o+=a,r[r.length-1]=o):(r.push(a),o=a)}return e.key=n,r}return l(t,c,e)};return c},htmlFor:function(n){var r=function(t,e){return e=e||{},Array.isArray(t)?t.map(function(t){return r(t,e)}).join(""):n(t,r,e)};return r},defaultParse:function(){return"undefined"!=typeof console&&console.warn("defaultParse is deprecated, please use `defaultImplicitParse`"),U.apply(null,arguments)},defaultOutput:function(){return"undefined"!=typeof console&&console.warn("defaultOutput is deprecated, please use `defaultReactOutput`"),W.apply(null,arguments)}}});