UNPKG

15 kBJavaScriptView Raw
1import e from"react";function n(){return(n=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}var t=/[\'\"]/,r={accesskey:"accessKey",allowfullscreen:"allowFullScreen",allowtransparency:"allowTransparency",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",classid:"classId",colspan:"colSpan",contenteditable:"contentEditable",contextmenu:"contextMenu",crossorigin:"crossOrigin",enctype:"encType",for:"htmlFor",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",inputmode:"inputMode",keyparams:"keyParams",keytype:"keyType",marginheight:"marginHeight",marginwidth:"marginWidth",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",novalidate:"noValidate",radiogroup:"radioGroup",readonly:"readOnly",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"},a={amp:"&",apos:"'",gt:">",lt:"<",nbsp:" ",quot:"“"},c=["style","script"],o=/([-A-Z0-9_:]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|(?:\{((?:\\.|{[^}]*?}|[^}])*)\})))?/gi,i=/mailto:/i,l=/\n{2,}$/,u=/^( *>[^\n]+(\n[^\n]+)*\n*)+\n{2,}/,s=/^ *> ?/gm,f=/^ {2,}\n/,p=/^(?:( *[-*_]) *){3,}(?:\n *)+\n/,d=/^\s*(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n *)+\n?/,m=/^(?: {4}[^\n]+\n*)+(?:\n *)+\n?/,g=/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,h=/^(?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.*?`|~+.*?~+|.)*?)\1(?!\1|\w)/,J=/^~~((?:\[.*?\]|<.*?>(?:.*?<.*?>)?|`.*?`|.)*?)~~/,Y=/^\\([^0-9A-Za-z\s])/,ee=/^[\s\S]+?(?=[^0-9A-Z\s\u00c0-\uffff&;.()'"]|\d+\.|\n\n| {2,}\n|\w+:\S|$)/i,ne=/(^\n+|\n+$|\s+$)/g,te=/^([ \t]*)/,re=/\\([^0-9A-Z\s])/gi,ae=new RegExp("^( *)((?:[*+-]|\\d+\\.)) +"),ce=new RegExp("( *)((?:[*+-]|\\d+\\.)) +[^\\n]*(?:\\n(?!\\1(?:[*+-]|\\d+\\.) )[^\\n]*)*(\\n|$)","gm"),oe=new RegExp("^( *)((?:[*+-]|\\d+\\.)) [\\s\\S]+?(?:\\n{2,}(?! )(?!\\1(?:[*+-]|\\d+\\.) (?!(?:[*+-]|\\d+\\.) ))\\n*|\\s*\\n*$)"),ie="(?:\\[[^\\]]*\\]|[^\\[\\]]|\\](?=[^\\[]*\\]))*",le=new RegExp("^\\[("+ie+")\\]\\(\\s*<?((?:[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*\\)"),ue=new RegExp("^!\\[("+ie+")\\]\\(\\s*<?((?:[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*\\)"),se=[u,m,d,H,A,I,w,O,ce,oe,X,R];function fe(e){return e.replace(/[ÀÁÂÃÄÅàáâãäåæÆ]/g,"a").replace(/[çÇ]/g,"c").replace(/[ðÐ]/g,"d").replace(/[ÈÉÊËéèêë]/g,"e").replace(/[ÏïÎîÍíÌì]/g,"i").replace(/[Ññ]/g,"n").replace(/[øØœŒÕõÔôÓóÒò]/g,"o").replace(/[ÜüÛûÚúÙù]/g,"u").replace(/[ŸÿÝý]/g,"y").replace(/[^a-z0-9- ]/gi,"").replace(/ /gi,"-").toLowerCase()}function pe(e){return V.test(e)?"right":F.test(e)?"center":q.test(e)?"left":null}function de(e,n,t){var r=t.inTable;t.inTable=!0;var a=n(e.trim(),t);t.inTable=r;var c=[[]];return a.forEach(function(e,n){"tableSeparator"===e.type?0!==n&&n!==a.length-1&&c.push([]):("text"!==e.type||null!=a[n+1]&&"tableSeparator"!==a[n+1].type||(e.content=e.content.replace(Z,"")),c[c.length-1].push(e))}),c}function me(e,n,t){t.inline=!0;var r=de(e[1],n,t),a=e[2].replace(P,"").split("|").map(pe),c=function(e,n,t){return e.trim().split("\n").map(function(e){return de(e,n,t)})}(e[3],n,t);return t.inline=!1,{align:a,cells:c,header:r,type:"table"}}function ge(e,n){return null==e.align[n]?{}:{textAlign:e.align[n]}}function he(e){return function(n,t){return t.inline?e.exec(n):null}}function ye(e){return function(n,t){return t.inline||t.simple?e.exec(n):null}}function ke(e){return function(n,t){return t.inline||t.simple?null:e.exec(n)}}function ve(e){return function(n){return e.exec(n)}}function xe(e){try{if(decodeURIComponent(e).replace(/[^A-Za-z0-9/:]/g,"").match(/^\s*(javascript|vbscript|data):/i))return null}catch(e){return null}return e}function be(e){return e.replace(re,"$1")}function He(e,n,t){var r=t.inline||!1,a=t.simple||!1;t.inline=!0,t.simple=!0;var c=e(n,t);return t.inline=r,t.simple=a,c}function Ae(e,n,t){var r=t.inline||!1,a=t.simple||!1;t.inline=!1,t.simple=!0;var c=e(n,t);return t.inline=r,t.simple=a,c}function Ie(e,n,t){return t.inline=!1,e(n+"\n\n",t)}var Se,we=function(e,n,t){return{content:He(n,e[1],t)}};function Me(){return{}}function Oe(){return null}function Ee(){return[].slice.call(arguments).filter(Boolean).join(" ")}function $e(e,n,t){for(var r=e,a=n.split(".");a.length&&void 0!==(r=r[a[0]]);)a.shift();return r||t}function Ce(e,n){var t=$e(n,e);return t?"function"==typeof t||"object"==typeof t&&"render"in t?t:$e(n,e+".component",e):e}function Ge(P,Z){void 0===Z&&(Z={}),Z.overrides=Z.overrides||{},Z.slugify=Z.slugify||fe,Z.namedCodesToUnicode=Z.namedCodesToUnicode?n({},a,Z.namedCodesToUnicode):a;var F=Z.createElement||e.createElement;function q(e,t){var r=$e(Z.overrides,e+".props",{});return F.apply(void 0,[Ce(e,Z.overrides),n({},t,r,{className:Ee(null==t?void 0:t.className,r.className)||void 0})].concat([].slice.call(arguments,2)))}function V(n){var t=!1;Z.forceInline?t=!0:Z.forceBlock||(t=!1===N.test(n));var r=Te(Le(t?n:n.replace(ne,"")+"\n\n",{inline:t}));if(null===Z.wrapper)return r;var a,c=Z.wrapper||(t?"span":"div");if(r.length>1||Z.forceWrapper)a=r;else{if(1===r.length)return"string"==typeof(a=r[0])?q("span",{key:"outer"},a):a;a=null}return e.createElement(c,{key:"outer"},a)}function re(n){var a=n.match(o);return a?a.reduce(function(n,a,c){var o=a.indexOf("=");if(-1!==o){var i=function(e){return-1!==e.indexOf("-")&&null===e.match(M)&&(e=e.replace(z,function(e,n){return n.toUpperCase()})),e}(a.slice(0,o)).trim(),l=function(e){return e?(t.test(e.charAt(0))&&(e=e.substr(1)),t.test(e.charAt(e.length-1))&&(e=e.substr(0,e.length-1)),e):""}(a.slice(o+1).trim()),u=r[i]||i,s=n[u]=function(e,n){return"style"===e?n.split(/;\s?/).reduce(function(e,n){var t=n.slice(0,n.indexOf(":"));return e[t.replace(/(-[a-z])/g,function(e){return e[1].toUpperCase()})]=n.slice(t.length+1).trim(),e},{}):"href"===e?xe(n):(n.match(E)&&(n=n.slice(1,n.length-1)),"true"===n||"false"!==n&&n)}(i,l);"string"==typeof s&&(I.test(s)||O.test(s))&&(n[u]=e.cloneElement(V(s.trim()),{key:c}))}else"style"!==a&&(n[r[a]||a]=!0);return n},{}):void 0}var ie=[],pe={},de={blockQuote:{match:ke(u),order:Se.HIGH,parse:function(e,n,t){return{content:n(e[0].replace(s,""),t)}},react:function(e,n,t){return q("blockquote",{key:t.key},n(e.content,t))}},breakLine:{match:ve(f),order:Se.HIGH,parse:Me,react:function(e,n,t){return q("br",{key:t.key})}},breakThematic:{match:ke(p),order:Se.HIGH,parse:Me,react:function(e,n,t){return q("hr",{key:t.key})}},codeBlock:{match:ke(m),order:Se.MAX,parse:function(e){return{content:e[0].replace(/^ {4}/gm,"").replace(/\n+$/,""),lang:void 0}},react:function(e,n,t){return q("pre",{key:t.key},q("code",{className:e.lang?"lang-"+e.lang:""},e.content))}},codeFenced:{match:ke(d),order:Se.MAX,parse:function(e){return{content:e[3],lang:e[2]||void 0,type:"codeBlock"}}},codeInline:{match:ye(g),order:Se.LOW,parse:function(e){return{content:e[2]}},react:function(e,n,t){return q("code",{key:t.key},e.content)}},footnote:{match:ke(k),order:Se.MAX,parse:function(e){return ie.push({footnote:e[2],identifier:e[1]}),{}},react:Oe},footnoteReference:{match:he(v),order:Se.HIGH,parse:function(e){return{content:e[1],target:"#"+Z.slugify(e[1])}},react:function(e,n,t){return q("a",{key:t.key,href:xe(e.target)},q("sup",{key:t.key},e.content))}},gfmTask:{match:he(b),order:Se.HIGH,parse:function(e){return{completed:"x"===e[1].toLowerCase()}},react:function(e,n,t){return q("input",{checked:e.completed,key:t.key,readOnly:!0,type:"checkbox"})}},heading:{match:ke(H),order:Se.HIGH,parse:function(e,n,t){return{content:He(n,e[2],t),id:Z.slugify(e[2]),level:e[1].length}},react:function(e,n,t){return e.tag="h"+e.level,q(e.tag,{id:e.id,key:t.key},n(e.content,t))}},headingSetext:{match:ke(A),order:Se.MAX,parse:function(e,n,t){return{content:He(n,e[1],t),level:"="===e[2]?1:2,type:"heading"}}},htmlComment:{match:ve(w),order:Se.HIGH,parse:function(){return{}},react:Oe},image:{match:ye(ue),order:Se.HIGH,parse:function(e){return{alt:e[1],target:be(e[2]),title:e[3]}},react:function(e,n,t){return q("img",{key:t.key,alt:e.alt||void 0,title:e.title||void 0,src:xe(e.target)})}},link:{match:he(le),order:Se.LOW,parse:function(e,n,t){return{content:Ae(n,e[1],t),target:be(e[2]),title:e[3]}},react:function(e,n,t){return q("a",{key:t.key,href:xe(e.target),title:e.title},n(e.content,t))}},linkAngleBraceStyleDetector:{match:he(G),order:Se.MAX,parse:function(e){return{content:[{content:e[1],type:"text"}],target:e[1],type:"link"}}},linkBareUrlDetector:{match:function(e,n){return n.inAnchor?null:he($)(e,n)},order:Se.MAX,parse:function(e){return{content:[{content:e[1],type:"text"}],target:e[1],title:void 0,type:"link"}}},linkMailtoDetector:{match:he(C),order:Se.MAX,parse:function(e){var n=e[1],t=e[1];return i.test(t)||(t="mailto:"+t),{content:[{content:n.replace("mailto:",""),type:"text"}],target:t,type:"link"}}},list:{match:function(e,n,t){var r=T.exec(t);return!r||!n._list&&n.inline?null:oe.exec(e=r[1]+e)},order:Se.HIGH,parse:function(e,n,t){var r=e[2],a=r.length>1,c=a?+r:void 0,o=e[0].replace(l,"\n").match(ce),i=!1;return{items:o.map(function(e,r){var a=ae.exec(e)[0].length,c=new RegExp("^ {1,"+a+"}","gm"),l=e.replace(c,"").replace(ae,""),u=r===o.length-1,s=-1!==l.indexOf("\n\n")||u&&i;i=s;var f,p=t.inline,d=t._list;t._list=!0,s?(t.inline=!1,f=l.replace(L,"\n\n")):(t.inline=!0,f=l.replace(L,""));var m=n(f,t);return t.inline=p,t._list=d,m}),ordered:a,start:c}},react:function(e,n,t){return q(e.ordered?"ol":"ul",{key:t.key,start:e.start},e.items.map(function(e,r){return q("li",{key:r},n(e,t))}))}},newlineCoalescer:{match:ke(h),order:Se.LOW,parse:Me,react:function(){return"\n"}},paragraph:{match:ke(R),order:Se.LOW,parse:we,react:function(e,n,t){return q("p",{key:t.key},n(e.content,t))}},ref:{match:he(W),order:Se.MAX,parse:function(e){return pe[e[1]]={target:e[2],title:e[4]},{}},react:Oe},refImage:{match:ye(_),order:Se.MAX,parse:function(e){return{alt:e[1]||void 0,ref:e[2]}},react:function(e,n,t){return q("img",{key:t.key,alt:e.alt,src:xe(pe[e.ref].target),title:pe[e.ref].title})}},refLink:{match:he(j),order:Se.MAX,parse:function(e,n,t){return{content:n(e[1],t),fallbackContent:n(e[0].replace(B,"\\$1"),t),ref:e[2]}},react:function(e,n,t){return pe[e.ref]?q("a",{key:t.key,href:xe(pe[e.ref].target),title:pe[e.ref].title},n(e.content,t)):q("span",{key:t.key},n(e.fallbackContent,t))}},table:{match:ke(X),order:Se.HIGH,parse:me,react:function(e,n,t){return q("table",{key:t.key},q("thead",null,q("tr",null,e.header.map(function(r,a){return q("th",{key:a,style:ge(e,a)},n(r,t))}))),q("tbody",null,e.cells.map(function(r,a){return q("tr",{key:a},r.map(function(r,a){return q("td",{key:a,style:ge(e,a)},n(r,t))}))})))}},tableSeparator:{match:function(e,n){return n.inTable?D.exec(e):null},order:Se.HIGH,parse:function(){return{type:"tableSeparator"}},react:function(){return" | "}},text:{match:ve(ee),order:Se.MIN,parse:function(e){return{content:e[0].replace(S,function(e,n){return Z.namedCodesToUnicode[n]?Z.namedCodesToUnicode[n]:e})}},react:function(e){return e.content}},textBolded:{match:ye(K),order:Se.MED,parse:function(e,n,t){return{content:n(e[2],t)}},react:function(e,n,t){return q("strong",{key:t.key},n(e.content,t))}},textEmphasized:{match:ye(Q),order:Se.LOW,parse:function(e,n,t){return{content:n(e[2],t)}},react:function(e,n,t){return q("em",{key:t.key},n(e.content,t))}},textEscaped:{match:ye(Y),order:Se.HIGH,parse:function(e){return{content:e[1],type:"text"}}},textStrikethroughed:{match:ye(J),order:Se.LOW,parse:we,react:function(e,n,t){return q("del",{key:t.key},n(e.content,t))}}};!0!==Z.disableParsingRawHTML&&(de.htmlBlock={match:ve(I),order:Se.HIGH,parse:function(e,n,t){var r,a=e[3].match(te),o=new RegExp("^"+a[1],"gm"),i=e[3].replace(o,""),l=(r=i,se.some(function(e){return e.test(r)})?Ie:He),u=e[1].toLowerCase(),s=-1!==c.indexOf(u);t.inAnchor=t.inAnchor||"a"===u;var f=s?e[3]:l(n,i,t);return t.inAnchor=!1,{attrs:re(e[2]),content:f,noInnerParse:s,tag:s?u:e[1]}},react:function(e,n,t){return q(e.tag,Object.assign({key:t.key},e.attrs),e.noInnerParse?e.content:n(e.content,t))}},de.htmlSelfClosing={match:ve(O),order:Se.HIGH,parse:function(e){return{attrs:re(e[2]||""),tag:e[1]}},react:function(e,n,t){return q(e.tag,Object.assign({},e.attrs,{key:t.key}))}});var Ge,Le=function(e){var n=Object.keys(e);function t(r,a){for(var c=[],o="";r;)for(var i=0;i<n.length;){var l=n[i],u=e[l],s=u.match(r,a,o);if(s){var f=s[0];r=r.substring(f.length);var p=u.parse(s,t,a);null==p.type&&(p.type=l),c.push(p),o=f;break}i++}return c}return n.sort(function(n,t){var r=e[n].order,a=e[t].order;return r!==a?r-a:n<t?-1:1}),function(e,n){return t(function(e){return e.replace(y,"\n").replace(x,"").replace(U," ")}(e),n)}}(de),Te=(Ge=function(e){return function(n,t,r){return e[n.type].react(n,t,r)}}(de),function e(n,t){if(void 0===t&&(t={}),Array.isArray(n)){for(var r=t.key,a=[],c=!1,o=0;o<n.length;o++){t.key=o;var i=e(n[o],t),l="string"==typeof i;l&&c?a[a.length-1]+=i:a.push(i),c=l}return t.key=r,a}return Ge(n,e,t)}),ze=V(P);return ie.length&&ze.props.children.push(q("footer",{key:"footer"},ie.map(function(e){return q("div",{id:Z.slugify(e.identifier),key:e.identifier},e.identifier,Te(Le(e.footnote,{inline:!0})))}))),ze}!function(e){e[e.MAX=0]="MAX",e[e.HIGH=1]="HIGH",e[e.MED=2]="MED",e[e.LOW=3]="LOW",e[e.MIN=4]="MIN"}(Se||(Se={}));export default function(n){var t=n.children,r=n.options,a=function(e,n){if(null==e)return{};var t,r,a={},c=Object.keys(e);for(r=0;r<c.length;r++)n.indexOf(t=c[r])>=0||(a[t]=e[t]);return a}(n,["children","options"]);return e.cloneElement(Ge(t,r),a)}export{Ge as compiler};
2//# sourceMappingURL=index.module.js.map