GGD/node_modules/prettier/parser-markdown.js

14 lines
176 KiB
JavaScript
Raw Normal View History

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).prettierPlugins=e.prettierPlugins||{},e.prettierPlugins.markdown=t())}(this,(function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r=function(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var u in r)n.call(r,u)&&(e[u]=r[u])}return e},n=Object.prototype.hasOwnProperty;var u={exports:{}},i=void 0!==i?i:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},o=[],a=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array,s=!1;function l(){s=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t<r;++t)o[t]=e[t],a[e.charCodeAt(t)]=t;a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63}function f(e){return o[e>>18&63]+o[e>>12&63]+o[e>>6&63]+o[63&e]}function D(e,t,r){for(var n,u=[],i=t;i<r;i+=3)n=(e[i]<<16)+(e[i+1]<<8)+e[i+2],u.push(f(n));return u.join("")}function p(e){var t;s||l();for(var r=e.length,n=r%3,u="",i=[],a=16383,c=0,f=r-n;c<f;c+=a)i.push(D(e,c,c+a>f?f:c+a));return 1===n?(t=e[r-1],u+=o[t>>2],u+=o[t<<4&63],u+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],u+=o[t>>10],u+=o[t>>4&63],u+=o[t<<2&63],u+="="),i.push(u),i.join("")}function h(e,t,r,n,u){var i,o,a=8*u-n-1,c=(1<<a)-1,s=c>>1,l=-7,f=r?u-1:0,D=r?-1:1,p=e[t+f];for(f+=D,i=p&(1<<-l)-1,p>>=-l,l+=a;l>0;i=256*i+e[t+f],f+=D,l-=8);for(o=i&(1<<-l)-1,i>>=-l,l+=n;l>0;o=256*o+e[t+f],f+=D,l-=8);if(0===i)i=1-s;else{if(i===c)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),i-=s}return(p?-1:1)*o*Math.pow(2,i-n)}function d(e,t,r,n,u,i){var o,a,c,s=8*i-u-1,l=(1<<s)-1,f=l>>1,D=23===u?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,h=n?1:-1,d=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+f>=1?D/c:D*Math.pow(2,1-f))*c>=2&&(o++,c/=2),o+f>=l?(a=0,o=l):o+f>=1?(a=(t*c-1)*Math.pow(2,u),o+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,u),o=0));u>=8;e[r+p]=255&a,p+=h,a/=256,u-=8);for(o=o<<u|a,s+=u;s>0;e[r+p]=255&o,p+=h,o/=256,s-=8);e[r+p-h]|=128*d}var g={}.toString,m=Array.isArray||function(e){return"[object Array]"==g.call(e)};function E(){return y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function v(e,t){if(E()<t)throw new RangeError("Invalid typed array length");return y.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=y.prototype:(null===e&&(e=new y(t)),e.length=t),e}function y(e,t,r){if(!(y.TYPED_ARRAY_SUPPORT||this instanceof y))return new y(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return A(this,e)}return b(this,e,t,r)}function b(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);y.TYPED_ARRAY_SUPPORT?(e=t).__proto__=y.prototype:e=w(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!y.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|O(t,r),u=(e=v(e,n)).write(t,r);u!==n&&(e=e.slice(0,u));return e}(e,t,r):function(e,t){if(k(t)){var r=0|F(t.length);return 0===(e=v(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?v(e,0):w(e,t);if("Buffer"===t.type&&m(t.data))return w(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object
/*!
* repeat-string <https://github.com/jonschlinkert/repeat-string>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/;var Nr,Lr="",Pr=function(e,t){if("string"!=typeof e)throw new TypeError("expected a string");if(1===t)return e;if(2===t)return e+e;var r=e.length*t;if(Nr!==e||void 0===Nr)Nr=e,Lr="";else if(Lr.length>=r)return Lr.substr(0,r);for(;r>Lr.length&&t>1;)1&t&&(Lr+=e),t>>=1,e+=e;return Lr=(Lr+=e).substr(0,r)};var qr=function(e){return String(e).replace(/\n+$/,"")};var jr=qr,_r=function(e,t,r){var n,u,i,o=-1,a=t.length,c="",s="",l="",f="";for(;++o<a;)if(n=t.charAt(o),i)if(i=!1,c+=l,s+=f,l="",f="","\n"===n)l=n,f=n;else for(c+=n,s+=n;++o<a;){if(!(n=t.charAt(o))||"\n"===n){f=n,l=n;break}c+=n,s+=n}else if(" "===n&&t.charAt(o+1)===n&&t.charAt(o+2)===n&&t.charAt(o+3)===n)l+=Ur,o+=3,i=!0;else if("\t"===n)l+=n,i=!0;else{for(u="";"\t"===n||" "===n;)u+=n,n=t.charAt(++o);if("\n"!==n)break;l+=u+n,f+=n}if(s)return!!r||e(c)({type:"code",lang:null,meta:null,value:jr(s)})},Ur=Pr(" ",4);var Mr=function(e,t,r){var n,u,i,o,a,c,s,l,f,D,p,h,d,g=this,m=g.options.gfm,E=t.length+1,v=0,y="";if(!m)return;for(;v<E&&((i=t.charAt(v))===Vr||i===Gr);)y+=i,v++;if(h=v,"~"!==(i=t.charAt(v))&&"`"!==i)return;v++,u=i,n=1,y+=i;for(;v<E&&(i=t.charAt(v))===u;)y+=i,n++,v++;if(n<3)return;for(;v<E&&((i=t.charAt(v))===Vr||i===Gr);)y+=i,v++;o="",s="";for(;v<E&&(i=t.charAt(v))!==zr&&("`"!==u||i!==u);)i===Vr||i===Gr?s+=i:(o+=s+i,s=""),v++;if((i=t.charAt(v))&&i!==zr)return;if(r)return!0;(d=e.now()).column+=y.length,d.offset+=y.length,y+=o,o=g.decode.raw(g.unescape(o),d),s&&(y+=s);s="",D="",p="",l="",f="";var b=!0;for(;v<E;)if(i=t.charAt(v),l+=D,f+=p,D="",p="",i===zr){for(b?(y+=i,b=!1):(D+=i,p+=i),s="",v++;v<E&&(i=t.charAt(v))===Vr;)s+=i,v++;if(D+=s,p+=s.slice(h),!(s.length>=4)){for(s="";v<E&&(i=t.charAt(v))===u;)s+=i,v++;if(D+=s,p+=s,!(s.length<n)){for(s="";v<E&&((i=t.charAt(v))===Vr||i===Gr);)D+=i,p+=i,v++;if(!i||i===zr)break}}}else l+=i,p+=i,v++;y+=l+D,v=-1,E=o.length;for(;++v<E;)if((i=o.charAt(v))===Vr||i===Gr)a||(a=o.slice(0,v));else if(a){c=o.slice(v);break}return e(y)({type:"code",lang:a||o||null,meta:c||null,value:f})},zr="\n",Gr="\t",Vr=" ";var Yr={exports:{}};!function(e,t){(t=e.exports=function(e){return e.replace(/^\s*|\s*$/g,"")}).left=function(e){return e.replace(/^\s*/,"")},t.right=function(e){return e.replace(/\s*$/,"")}}(Yr,Yr.exports);var $r=function(e,t,r,n){var u,i,o=e.length,a=-1;for(;++a<o;)if(u=e[a],(void 0===(i=u[1]||{}).pedantic||i.pedantic===r.options.pedantic)&&(void 0===i.commonmark||i.commonmark===r.options.commonmark)&&t[u[0]].apply(r,n))return!0;return!1};var Hr=Yr.exports,Xr=$r,Zr=function(e,t,r){var n,u,i,o,a,c,s,l,f,D=this,p=D.offset,h=D.blockTokenizers,d=D.interruptBlockquote,g=e.now(),m=g.line,E=t.length,v=[],y=[],b=[],C=0;for(;C<E&&(" "===(u=t.charAt(C))||"\t"===u);)C++;if(">"!==t.charAt(C))return;if(r)return!0;C=0;for(;C<E;){for(o=t.indexOf("\n",C),s=C,l=!1,-1===o&&(o=E);C<E&&(" "===(u=t.charAt(C))||"\t"===u);)C++;if(">"===t.charAt(C)?(C++,l=!0," "===t.charAt(C)&&C++):C=s,a=t.slice(C,o),!l&&!Hr(a)){C=s;break}if(!l&&(i=t.slice(C),Xr(d,h,D,[e,i,!0])))break;c=s===C?a:t.slice(s,o),b.push(C-s),v.push(c),y.push(a),C=o+1}C=-1,E=b.length,n=e(v.join("\n"));for(;++C<E;)p[m]=(p[m]||0)+b[C],m++;return f=D.enterBlock(),y=D.tokenizeBlock(y.join("\n"),g),f(),n({type:"blockquote",children:y})};var Wr=function(e,t,r){var n,u,i,o=this.options.pedantic,a=t.length+1,c=-1,s=e.now(),l="",f="";for(;++c<a;){if((n=t.charAt(c))!==Kr&&n!==Jr){c--;break}l+=n}i=0;for(;++c<=a;){if((n=t.charAt(c))!==Qr){c--;break}l+=n,i++}if(i>6)return;if(!i||!o&&t.charAt(c+1)===Qr)return;a=t.length+1,u="";for(;++c<a;){if((n=t.charAt(c))!==Kr&&n!==Jr){c--;break}u+=n}if(!o&&0===u.length&&n&&"\n"!==n)return;if(r)return!0;l+=u,u="",f="";for(;++c<a&&(n=t.charAt(c))&&"\n"!==n;)if(n===Kr||n===Jr||n===Qr){for(;n===Kr||n===Jr;)u+=n,n=t.charAt(++c);if(o||!f||u||n!==Qr){for(;n===Qr;)u+=n,n=t.charAt(++c);for(;n===Kr||n===Jr;)u+=n,n=t.charAt(++c);c--}else f+=n}else f+=u+n,u="";return s.column+=l.length,s.offset+=l.length,e(l+=f+u)({type:"heading",depth:i,children:this.tokenizeInline(f,s)})},Jr="\t",Kr=" ",Qr="#";var en=function(e,t,r){var n,u,i,o,a=-1,c=t.length+1,s="";for(;++a<c&&("\t"===(n=t
/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/;var oo=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},ao=Object.prototype.hasOwnProperty,co=Object.prototype.toString,so=Object.defineProperty,lo=Object.getOwnPropertyDescriptor,fo=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===co.call(e)},Do=function(e){if(!e||"[object Object]"!==co.call(e))return!1;var t,r=ao.call(e,"constructor"),n=e.constructor&&e.constructor.prototype&&ao.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!r&&!n)return!1;for(t in e);return void 0===t||ao.call(e,t)},po=function(e,t){so&&"__proto__"===t.name?so(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},ho=function(e,t){if("__proto__"===t){if(!ao.call(e,t))return;if(lo)return lo(e,t).value}return e[t]},go=[].slice,mo=function(e,t){var r;return function(){var t,i=go.call(arguments,0),o=e.length>i.length;o&&i.push(n);try{t=e.apply(null,i)}catch(e){if(o&&r)throw e;return n(e)}o||(t&&"function"==typeof t.then?t.then(u,n):t instanceof Error?n(t):u(t))};function n(){r||(r=!0,t.apply(null,arguments))}function u(e){n(null,e)}};var Eo=mo,vo=bo;bo.wrap=Eo;var yo=[].slice;function bo(){var e=[],t={run:function(){var t=-1,r=yo.call(arguments,0,-1),n=arguments[arguments.length-1];if("function"!=typeof n)throw new Error("Expected function as last argument, not "+n);function u(i){var o=e[++t],a=yo.call(arguments,0),c=a.slice(1),s=r.length,l=-1;if(i)n(i);else{for(;++l<s;)null!==c[l]&&void 0!==c[l]||(c[l]=r[l]);r=c,o?Eo(o,u).apply(null,r):n.apply(null,[null].concat(r))}}u.apply(null,[null].concat(r))},use:function(r){if("function"!=typeof r)throw new Error("Expected `fn` to be a function, not "+r);return e.push(r),t}};return t}var Co={}.hasOwnProperty;function Ao(e){return e&&"object"==typeof e||(e={}),Fo(e.line)+":"+Fo(e.column)}function wo(e){return e&&"object"==typeof e||(e={}),Ao(e.start)+"-"+Ao(e.end)}function Fo(e){return e&&"number"==typeof e?e:1}var ko=function(e){if(!e||"object"!=typeof e)return"";if(Co.call(e,"position")||Co.call(e,"type"))return wo(e.position);if(Co.call(e,"start")||Co.call(e,"end"))return wo(e);if(Co.call(e,"line")||Co.call(e,"column"))return Ao(e);return""},Oo=So;function xo(){}xo.prototype=Error.prototype,So.prototype=new xo;var To=So.prototype;function So(e,t,r){var n,u,i;"string"==typeof t&&(r=t,t=null),n=function(e){var t,r=[null,null];"string"==typeof e&&(-1===(t=e.indexOf(":"))?r[1]=e:(r[0]=e.slice(0,t),r[1]=e.slice(t+1)));return r}(r),u=ko(t)||"1:1",i={start:{line:null,column:null},end:{line:null,column:null}},t&&t.position&&(t=t.position),t&&(t.start?(i=t,t=t.start):i.start=t),e.stack&&(this.stack=e.stack,e=e.message),this.message=e,this.name=u,this.reason=e,this.line=t?t.line:null,this.column=t?t.column:null,this.location=i,this.source=n[0],this.ruleId=n[1]}function Ro(e,t){for(var r=0,n=e.length-1;n>=0;n--){var u=e[n];"."===u?e.splice(n,1):".."===u?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}To.file="",To.name="",To.reason="",To.message="",To.stack="",To.fatal=null,To.column=null,To.line=null;var Io=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,Bo=function(e){return Io.exec(e).slice(1)};function No(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(e=n+"/"+e,t="/"===n.charAt(0))}return e=Ro(Go(e.split("/"),(function(e){return!!e})),!t).join("/"),(t?"/":"")+e||"."}function Lo(e){var t=Po(e),r="/"===Vo(e,-1);return e=Ro(Go(e.split("/"),(function(e){return!!e})),!t).join("/"),e||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function Po(e){return"/"===e.charAt(0)}function qo(){var e=Array.prototype.slice.call(arguments,0);return Lo(Go(e,(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))}function jo(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.s