Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lys-markdown-parser

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lys-markdown-parser - npm Package Compare versions

Comparing version 3.9.1 to 3.10.0

2

dist/index.umd.js

@@ -1,1 +0,1 @@

"use strict";function _objectWithoutProperties(c,d){if(null==c)return{};var a,f,h=_objectWithoutPropertiesLoose(c,d);if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(c);for(f=0;f<g.length;f++)a=g[f],!(0<=d.indexOf(a))&&Object.prototype.propertyIsEnumerable.call(c,a)&&(h[a]=c[a])}return h}function _objectWithoutPropertiesLoose(c,d){if(null==c)return{};var a,f,h={},g=Object.keys(c);for(f=0;f<g.length;f++)a=g[f],0<=d.indexOf(a)||(h[a]=c[a]);return h}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(c,d){for(var a,e=0;e<d.length;e++)a=d[e],a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(c,a.key,a)}function _createClass(c,d,a){return d&&_defineProperties(c.prototype,d),a&&_defineProperties(c,a),c}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(c,d){var e,a=[],b=!0,h=!1;try{for(var i,j=c[Symbol.iterator]();!(b=(i=j.next()).done)&&(a.push(i.value),!(d&&a.length===d));b=!0);}catch(b){h=!0,e=b}finally{try{b||null==j["return"]||j["return"]()}finally{if(h)throw e}}return a}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _objectSpread(a){for(var b=1;b<arguments.length;b++){var f=null==arguments[b]?{}:arguments[b],d=Object.keys(f);"function"==typeof Object.getOwnPropertySymbols&&(d=d.concat(Object.getOwnPropertySymbols(f).filter(function(a){return Object.getOwnPropertyDescriptor(f,a).enumerable}))),d.forEach(function(b){_defineProperty(a,b,f[b])})}return a}function _defineProperty(c,d,a){return d in c?Object.defineProperty(c,d,{value:a,enumerable:!0,configurable:!0,writable:!0}):c[d]=a,c}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(a){if(Symbol.iterator in Object(a)||"[object Arguments]"===Object.prototype.toString.call(a))return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a)){for(var b=0,d=Array(a.length);b<a.length;b++)d[b]=a[b];return d}}var fuckMD=function(q){"use strict";function r(c,d){if(!c)return{type:"add",prevNode:c,nextNode:d};if(!d)return{type:"del",prevNode:c,nextNode:d};if(c.type!==d.type)return{type:"replace",prevNode:c,nextNode:d};var e={type:"update",prevNode:c,nextNode:d,propsChange:[],children:[]},f=j(c,d);if(f.length){var a;(a=e.propsChange).push.apply(a,_toConsumableArray(f))}return(e.children=s(c,d).filter(function(a){return a}),0<e.propsChange.length+e.children.length)?e:(d.__htmlNode=c.__htmlNode,d.__update=c.__update,e)}function s(c,a){var b=c.children,f=void 0===b?[]:b,g=a.children,d=void 0===g?[]:g,h=[],i=[],j=f.filter(function(a){return!!d.some(function(b){return b.type===a.type})||(h.push(r(a,null)),!1)});d.forEach(function(a){j.some(function(b,c){return b.type===a.type&&(j[c]={isDel:!0,ele:b},!0)})}),j.filter(function(a){return!a.isDel}).forEach(function(b){return h.push(r(b,null))});var k=j.filter(function(a){return a.isDel}).map(function(a){return a.ele});return d.forEach(function(c,d){var e=k.some(function(e,f){if(e.type===c.type){k.splice(f,1),k.splice(d>f?d-1:d,0,{used:!0,ele:e}),f!==d&&i.push({type:"move",prevNode:e,nextNode:c,current:f,moveTo:d>f?d+1:d});var a=r(e,c);return i.push(a),!0}return!1});if(!e){k.splice(d,0,{add:!0,item:c});var a=r(null,c);i.push(_objectSpread({},a,{moveTo:d}))}}),h.concat(i,[],[])}function j(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},d=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},a=Object.keys(e),c=Object.keys(d),f=[];return a.forEach(function(a){return["__htmlNode","__parent","__update","children","type"].includes(a)?void 0:c.includes(a)?void(e[a]!==d[a]&&f.push({type:"change",key:a,prevNode:e,nextNode:d})):void f.push({type:"del",key:a,prevNode:e,nextNode:d})}),c.forEach(function(b){a.includes(b)||f.push({type:"add",key:b,prevNode:e,nextNode:d})}),f}function b(){for(var a,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",f=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"[",d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"]",g=0,h=-1,i=0,j=function(a){return e.slice(g,g+a.length)===a};g<e.length;){if(a=e[g],!i)if(!a.trim()){g+=1;continue}else if(j(f)){h=g,i+=1,g+=f.length;continue}else return[void 0,e];if(j(d)?(i-=1,g+=d.length):j(f)?(i+=1,g+=f.length):g+=1,!i)return[e.slice(h+f.length,g-d.length),e.slice(g)]}return[void 0,e]}function a(){var c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",d=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",a=c.indexOf(d);return[c.slice(0,a),c.slice(a+d.length)]}function t(){function n(a,b){var c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},d=c.isPush,e=j;j=a,a.__parent=j,b&&b(),j=e,(void 0===d||d)&&j.children.push(a)}function o(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";i=i.slice(a.length)}function d(a){return[c.head,c.ul,c.code,c.queto].some(function(b){return b.test(a)})}function x(){function b(){var c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",d=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,a=c.split("\n")[d].trim();return /^\|.+\|$/.test(a)?a.split("|").slice(1,-1):[]}var f=b(i,0),a=b(i,1),h=f.length;if(0!=h&&f.length==a.length&&a.every(function(a){return /^-+$/.test(a.replace(/\s/g,""))}))return n({type:"table",children:[]},function(){i=i.replace(/(.+)\n?/,function(b,c){return n({type:"thead",children:[]},function(){n({type:"tr",children:[]},function(){c.trim().split("|").slice(1,-1).map(function(b){n({type:"th",children:[]},function(){e(b)})})})}),""}),i=i.replace(/.+\n?/,""),n({type:"tbody",children:[]},function(){for(var a,b=function b(){var b=(i.match(/^.+\n?/)||[])[0];return b?d(b)?"break":void(i=i.replace(b,""),n({type:"tr",children:[]},function(){var c,f=b.trim().split("|");f=f[0]?f.slice(0,h):f.slice(1).slice(0,h),(c=f).push.apply(c,_toConsumableArray(Array(h-f.length).fill(""))),f.forEach(function(b){n({type:"td",children:[]},function(){e(b)})})})):"break"};a=b(),"break"!==a;);})}),!0}function e(){var d=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";if(d){if(c.url.test(d))return void e(d.replace(c.url,function(d,a,b){return n({type:"a",href:b,value:a,children:[]},function(){e(a)}),""}));if(c.blod.test(d))return void e(d.replace(c.blod,function(b,c){return n({type:"b",children:[]},function(){e(c)}),""}));if(c.italic.test(d))return void e(d.replace(c.italic,function(b,c){return n({type:"i",children:[]},function(){e(c)}),""}));if(c.inlineCode.test(d))return void e(d.replace(c.inlineCode,function(b,c){return c&&n({type:"inlineCode",children:[]},function(){e(c)}),""}));if(c.video.test(d))return void e(d.replace(c.video,function(c,d,a){return j.children.push({type:"video",src:a,alt:d}),""}));if(c.audio.test(d))return d=d.replace(c.audio,function(c,d,a){return j.children.push({type:"audio",src:a,alt:d}),""}),void e(d);if(c.img.test(d))return void e(d.replace(c.img,function(c,d,a){return j.children.push({type:"img",src:a,alt:d}),""}));if("\n"==d[0])return j.children.push({type:"br"}),void e(d.slice(1));var g=j.children[j.children.length-1];g&&"text"===g.type?g.value+=d[0]:j.children.push({type:"text",value:f(d[0])}),e(d.slice(1))}}function f(a){return a.replace(/>/g,">").replace(/\\#/g,"#").replace(/\\`/g,"`").replace(/\\-/g,"-").replace(/\\\*/g,"*")}function g(){function m(){var b=Math.floor,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:-1;if(c){var d=(c.match(/.+\n?/)||[])[0],k=d.match(/\s*/)[0],h=b(k.length/5);if(/^[-+]\s+/.test(d.trim())){var i="+"==d.match(/\s*[-+]/)[0].trim();if(h==e+1){var l={type:"ul",listStyleType:i?"decimal":a[h%a.length],children:[]};return n(l,function(){m(e+1)}),void m(e)}if(h==e)return n({type:"li",children:[]},function(){e(d.replace(/\s*[-+]\s*/,""))}),c=c.slice(d.length),void m(e);if(h<e)return}var f=j.children[j.children.length-1];n(f,function(){e(d)},{isPush:!1}),c=c.slice(d.length),m(e)}}var c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";c="".concat(c,"\n");var a=["disc","circle","square"];m()}function h(){if(!/^\n{1,2}$/.test(i)&&i){if(/Reg.br/.test(i)){var d=i.match(c.br),f=_slicedToArray(d,1),k=f[0];return j.children.push({type:"br"}),o(k),void h()}if(c.head.test(i)){var l=i.match(c.head)||[],m=_slicedToArray(l,3),p=m[0],q=m[1],K=m[2],L={type:"h".concat(q.length),children:[]};return n(L,function(){e(K)}),o(p),void h()}if(c.queto.test(i)){var M=i.match(c.queto),N=_slicedToArray(M,2),r=N[0],v=N[1],D=b(v,"[","]"),E=_slicedToArray(D,2),O=E[0],P=E[1],Q={type:"queto",tag:O,children:[]},w=t(P.replace(/^\s*\n/,""));return Q.children=w.children,j.children.push(Q),j.children.push({type:"br"}),o(r),void h()}if(c.code.test(i)){var R=i.match(c.code),S=_slicedToArray(R,2),s=S[0],T=S[1],u=a(T,"\n").map(function(a){return a.trim()}),W=_slicedToArray(u,2),y=W[0],U=W[1];return j.children.push({type:"code",language:y,value:U}),o(s),void h()}if(c.ul.test(i)){var z=i.match(c.ul),A=_slicedToArray(z,2),B=A[0],C=A[1];return n(j,function(){g(C)},{isPush:!1}),j.children.push({type:"br"}),o(B),void h()}if(i.match(/.+\n/)&&/\|.+\|/.test(i.match(/.+\n/)[0].trim())&&x(i))return void h();if(c.hr.test(i)){var V=i.match(c.hr)||[],X=_slicedToArray(V,1),F=X[0];return void 0!==F&&j.children.push({type:"hr",children:[]}),o(F),void h()}if(c.text.test(i)){var G=i.match(c.text)||[""],H=_slicedToArray(G,1),I=H[0];return e(I),o(I),void h()}throw new Error("cannot handle str:".concat(i))}}var i=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";i+="\n\n";var j={children:[],type:"root"};return h(),j}function u(a,b){return b&&b.parentElement&&b.parentElement.insertBefore(a,b),a}function v(d){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:document.body;if(d){var f=d.nextNode;switch(d.type){case"del":{var b=d.prevNode.__htmlNode;b.parentElement||console.log("delete error::",d),b.parentElement.removeChild(b);break}case"add":{w(f,e,{beforeAppend:function(b){var c=e.childNodes[d.moveTo];if(c)return u(b,c),!0}});break}case"replace":{var c=d.prevNode.__htmlNode,k=document.createDocumentFragment();w(f,k),c.parentElement.replaceChild(k,c);break}case"move":{var l=d.moveTo,g=d.prevNode,h=g.__htmlNode.parentElement;h.childNodes[l]!==g.__htmlNode&&(h.childNodes[l]?u(g.__htmlNode,h.childNodes[l]):h.appendChild(g.__htmlNode));break}case"update":{var a=d.propsChange,i=d.children,j=d.prevNode,m=d.nextNode,n=j.__htmlNode;m.__htmlNode=n,j.__update&&(m.__update=j.__update),a.forEach(function(b){var c=b.key;switch(b.type){case"change":case"add":{var d=m[c];if(j.__update){j.__update(c,m);break}if(n instanceof Text){n.data=d;break}n.setAttribute(c,d);break}case"del":{n.removeAttribute(c);break}}}),i.forEach(function(b){return v(b,n)});break}default:console.error("canot handle type",d,d.type);}}}function f(b){var d=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";return"text"===b.type&&(d+=b.value||""),b.children&&b.children.forEach(function(b){d+=f(b)}),d}function w(e,b){var h,k=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};switch(e.type){case"audio":case"video":{if(/^<iframe(\s*.+)*><\/iframe>$/.test(e.src.trim())){h=document.createElement("div"),h.className="audio",h.innerHTML=e.src.replace("http://","//");var m=h.querySelector("iframe");m.style.cssText+=";max-width: 100%; max-height: 60vw; overflow: hidden;"}else h=document.createElement(e.type),h.src=e.src,h.alt=e.alt,h.controls="true";break}case"img":{var n=e.src.match(/\.(\d+)x(\d+)\./);if(n){var g=n.slice(1,3),l=_slicedToArray(g,2),a=l[0],i=l[1],p=e.src;h=document.createElement("div"),h.style.cssText=";position: relative; max-width: ".concat(a,"px; overflow: hidden; background: rgb(219, 221, 215);"),h.innerHTML="<div style=\"padding-top: ".concat(100*(i/a),"%;\">\n <img ").concat(LY.lazyLoad.caches.includes(p)?"src=\"".concat(p,"\" data-img-cache=\"true\""):"","\n class=\"lazy-load-img img-loading\"\n data-lazy-img=\"").concat(e.src,"\"\n style=\"position: absolute; width: 100%; height: 100%; top: 0;\" />\n </div>");break}else{h=document.createElement(e.type),h.src=e.src,h.alt=e.alt;break}}case"text":{var j=e.value;h=document.createTextNode(j);break}case"br":{h=document.createElement(e.type);break}case"a":{h=document.createElement(e.type),h.href=e.href,h.target="_blank";break}case"code":{h=document.createElement("pre");var q=document.createElement("code");e.__update=function(a,b){switch(a){case"language":{q.className=["highlight",b[a]||""].join(" ");break}case"value":{q.textContent=b[a];break}default:}},e.__update("language",e),e.__update("value",e),h.appendChild(q);break}case"inlineCode":{h=document.createElement("code"),h.className="inlineCode";break}case"h1":{h=document.createElement(e.type);var r=document.createElement("a"),d=f(e);r.href="#".concat(d),r.id=d,h.appendChild(r);break}case"ul":{h=document.createElement(e.type),e.__update=function(b,c){h.style.cssText+=";list-style-type:".concat(c[b],";")},e.__update("listStyleType",e);break}default:h=document.createElement(e.type),e.indent&&(h.style.cssText+=";padding-left: 2em;"),"table"==e.type&&h.setAttribute("border","1");}e.tag&&h.setAttribute("tag",e.tag),e.children&&e.children.forEach(function(a){return w(a,h)});var s=k.beforeAppend&&k.beforeAppend(h);return s||b.appendChild(h),e.__htmlNode=h,h}function e(a){function c(a){"text"==a.type&&(d+=a.value||""),"img"==a.type&&f.push(a.src),a.children&&a.children.forEach(c)}var d="",f=[];return c(a),{text:d,imgs:f}}function k(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",b=m[a];if(!b){var f=t(a);b=_objectSpread({root:f},e(f)),m[a]=b}return b}function d(a){return new Promise(function(b){if(h[a])return b();var c=function(){h[a]=!0,b()};if(a.endsWith(".js")){var d=document.createElement("script");d.onload=c,d.src=a,document.head.appendChild(d)}else if(a.endsWith(".css")){var e=document.createElement("link");e.onload=c,e.type="text/css",e.rel="stylesheet",e.charset="utf-8",e.href=a,document.head.appendChild(e)}})}function l(a,b){Promise.all(b.asset.map(d)).then(function(){window.hljs&&a&&(window.hljs.configure({tabReplace:4}),_toConsumableArray(a.querySelectorAll("code.highlight")).forEach(function(a){window.hljs.highlightBlock(a)}))})}function g(a){return _objectSpread({asset:[]},a)}var c={get hr(){return /(^-{3,}[^\n]+\n?)/},get code(){return /^`{3}(((?!```)[\s\S])*)`{3}/},get queto(){return /^>(((?!\n\n)[\s\S])*)\n\n/},get head(){return /^\s*(#{1,6})([^\n]*)\n?/},get ul(){return /^([-+]\s+((?!\n\n)[\s\S])*)\n\n/},get url(){return /^\[([^\]]+)\]\(([^)]+)\)/},get inlineCode(){return /^`([^`]*)`/},get br(){return /^\n/},get text(){return /^[^\n]*\n?/},get blod(){return /^\*{3}(((?!\*{3}).)*)\*{3}/},get italic(){return /^\*{2}(((?!\*{2}).)*)\*{2}/},get video(){return /^!{3}\[([^\]]*)\]\(([^)]+)\)/},get audio(){return /^!{2}\[([^\]]*)\]\(([^)]+)\)/},get img(){return /^!\[([^\]]*)\]\(([^)]+)\)/}},m={},h={},n=function(){function b(d,a){_classCallCheck(this,b),this.dom=d,this.config=a,this.prevRoot=null}return _createClass(b,[{key:"update",value:function(e){this.dom.classList.add("markdown");var a=k(e),d=r(this.prevRoot,a.root);this.prevRoot=a.root,v(d,this.dom);var b=g(this.config);b.useHighlight&&l(this.dom,b)}}]),b}();return q.Markdown=n,q.parser=t,q.trans=w,q.codeHighlight=l,q.getParseResult=k,q.markdown=function(a,d,c){a.innerHTML="",a.classList.add("markdown");var e=k(d);w(e.root,a),c=g(c),l(a,c)},q.markdownInfo=function(d){var a=k(d),e=a.root,b=_objectWithoutProperties(a,["root"]);return b},q}({});
"use strict";function _objectWithoutProperties(b,c){if(null==b)return{};var d,e,i=_objectWithoutPropertiesLoose(b,c);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(b);for(e=0;e<h.length;e++)d=h[e],!(0<=c.indexOf(d))&&Object.prototype.propertyIsEnumerable.call(b,d)&&(i[d]=b[d])}return i}function _objectWithoutPropertiesLoose(b,c){if(null==b)return{};var d,e,i={},h=Object.keys(b);for(e=0;e<h.length;e++)d=h[e],0<=c.indexOf(d)||(i[d]=b[d]);return i}function _classCallCheck(c,a){if(!(c instanceof a))throw new TypeError("Cannot call a class as a function")}function _defineProperties(b,c){for(var d,f=0;f<c.length;f++)d=c[f],d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(b,d.key,d)}function _createClass(b,c,d){return c&&_defineProperties(b.prototype,c),d&&_defineProperties(b,d),b}function _slicedToArray(c,a){return _arrayWithHoles(c)||_iterableToArrayLimit(c,a)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(f,c){var d,g=[],a=!0,k=!1;try{for(var l,m=f[Symbol.iterator]();!(a=(l=m.next()).done)&&(g.push(l.value),!(c&&g.length===c));a=!0);}catch(a){k=!0,d=a}finally{try{a||null==m["return"]||m["return"]()}finally{if(k)throw d}}return g}function _arrayWithHoles(b){if(Array.isArray(b))return b}function _objectSpread(c){for(var a=1;a<arguments.length;a++){var e=null==arguments[a]?{}:arguments[a],f=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(f=f.concat(Object.getOwnPropertySymbols(e).filter(function(b){return Object.getOwnPropertyDescriptor(e,b).enumerable}))),f.forEach(function(a){_defineProperty(c,a,e[a])})}return c}function _defineProperty(b,c,d){return c in b?Object.defineProperty(b,c,{value:d,enumerable:!0,configurable:!0,writable:!0}):b[c]=d,b}function _toConsumableArray(b){return _arrayWithoutHoles(b)||_iterableToArray(b)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(b){if(Symbol.iterator in Object(b)||"[object Arguments]"===Object.prototype.toString.call(b))return Array.from(b)}function _arrayWithoutHoles(c){if(Array.isArray(c)){for(var a=0,e=Array(c.length);a<c.length;a++)e[a]=c[a];return e}}var fuckMD=function(i){"use strict";function o(b,c){if(!b)return{type:"add",prevNode:b,nextNode:c};if(!c)return{type:"del",prevNode:b,nextNode:c};if(b.type!==c.type)return{type:"replace",prevNode:b,nextNode:c};var d={type:"update",prevNode:b,nextNode:c,propsChange:[],children:[]},e=q(b,c);if(e.length){var f;(f=d.propsChange).push.apply(f,_toConsumableArray(e))}return(d.children=p(b,c).filter(function(b){return b}),0<d.propsChange.length+d.children.length)?d:(c.__htmlNode=b.__htmlNode,c.__update=b.__update,d)}function p(e,c){var a=e.children,b=void 0===a?[]:a,f=c.children,g=void 0===f?[]:f,d=[],h=[],i=b.filter(function(c){return!!g.some(function(a){return a.type===c.type})||(d.push(o(c,null)),!1)});g.forEach(function(d){i.some(function(a,b){return a.type===d.type&&(i[b]={isDel:!0,ele:a},!0)})}),i.filter(function(b){return!b.isDel}).forEach(function(a){return d.push(o(a,null))});var j=i.filter(function(b){return b.isDel}).map(function(b){return b.ele});return g.forEach(function(b,c){var d=j.some(function(d,e){if(d.type===b.type){j.splice(e,1),j.splice(c>e?c-1:c,0,{used:!0,ele:d}),e!==c&&h.push({type:"move",prevNode:d,nextNode:b,current:e,moveTo:c>e?c+1:c});var f=o(d,b);return h.push(f),!0}return!1});if(!d){j.splice(c,0,{add:!0,item:b});var e=o(null,b);h.push(_objectSpread({},e,{moveTo:c}))}}),d.concat(h,[],[])}function q(){var g=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},d=Object.keys(g),b=Object.keys(e),c=[];return d.forEach(function(d){return["__htmlNode","__parent","__update","children","type"].includes(d)?void 0:b.includes(d)?void(g[d]!==e[d]&&c.push({type:"change",key:d,prevNode:g,nextNode:e})):void c.push({type:"del",key:d,prevNode:g,nextNode:e})}),b.forEach(function(a){d.includes(a)||c.push({type:"add",key:a,prevNode:g,nextNode:e})}),c}function s(){for(var b,c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"[",f=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"]",d=0,k=-1,l=0,m=function(b){return c.slice(d,d+b.length)===b};d<c.length;){if(b=c[d],!l)if(!b.trim()){d+=1;continue}else if(m(e)){k=d,l+=1,d+=e.length;continue}else return[void 0,c];if(m(f)?(l-=1,d+=f.length):m(e)?(l+=1,d+=e.length):d+=1,!l)return[c.slice(k+e.length,d-f.length),c.slice(d)]}return[void 0,c]}function b(){var b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",d=b.indexOf(c);return[b.slice(0,d),b.slice(d+c.length)]}function x(){function r(f,a){var b=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},c=b.isPush,d=p;p=f,f.__parent=p,a&&a(),p=d,(void 0===c||c)&&p.children.push(f)}function a(){var b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";o=o.slice(b.length)}function c(c){return[J.head,J.ul,J.code,J.queto].some(function(a){return a.test(c)})}function n(){function d(){var b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,d=b.split("\n")[c].trim();return /^\|.+\|$/.test(d)?d.split("|").slice(1,-1):[]}var b=d(o,0),e=d(o,1),a=b.length;if(0!=a&&b.length==e.length&&e.every(function(b){return /^-+$/.test(b.replace(/\s/g,""))}))return r({type:"table",children:[]},function(){o=o.replace(/(.+)\n?/,function(a,b){return r({type:"thead",children:[]},function(){r({type:"tr",children:[]},function(){b.trim().split("|").slice(1,-1).map(function(a){r({type:"th",children:[]},function(){k(a)})})})}),""}),o=o.replace(/.+\n?/,""),r({type:"tbody",children:[]},function(){for(var d,e=function d(){var d=(o.match(/^.+\n?/)||[])[0];return d?c(d)?"break":void(o=o.replace(d,""),r({type:"tr",children:[]},function(){var b,e=d.trim().split("|");e=e[0]?e.slice(0,a):e.slice(1).slice(0,a),(b=e).push.apply(b,_toConsumableArray(Array(a-e.length).fill(""))),e.forEach(function(a){r({type:"td",children:[]},function(){k(a)})})})):"break"};d=e(),"break"!==d;);})}),!0}function k(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";if(a){if(J.url.test(a))return void k(a.replace(J.url,function(c,d,a){return r({type:"a",href:a,value:d,children:[]},function(){k(d)}),""}));if(J.blod.test(a))return void k(a.replace(J.blod,function(a,b){return r({type:"b",children:[]},function(){k(b)}),""}));if(J.italic.test(a))return void k(a.replace(J.italic,function(a,b){return r({type:"i",children:[]},function(){k(b)}),""}));if(J.inlineCode.test(a))return void k(a.replace(J.inlineCode,function(a,b){return b&&r({type:"inlineCode",children:[]},function(){k(b)}),""}));if(J.video.test(a))return void k(a.replace(J.video,function(b,c,d){return p.children.push({type:"video",src:d,alt:c}),""}));if(J.audio.test(a))return a=a.replace(J.audio,function(b,c,d){return p.children.push({type:"audio",src:d,alt:c}),""}),void k(a);if(J.img.test(a))return void k(a.replace(J.img,function(b,c,d){return p.children.push({type:"img",src:d,alt:c}),""}));if("\n"==a[0])return p.children.push({type:"br"}),void k(a.slice(1));var b=p.children[p.children.length-1];b&&"text"===b.type?b.value+=a[0]:p.children.push({type:"text",value:e(a[0])}),k(a.slice(1))}}function e(b){return b.replace(/>/g,">").replace(/\\#/g,"#").replace(/\\`/g,"`").replace(/\\-/g,"-").replace(/\\\*/g,"*")}function d(){function g(){var a=Math.floor,c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:-1;if(j){var e=(j.match(/.+\n?/)||[])[0],d=e.match(/\s*/)[0],k=a(d.length/5);if(/^[-+]\s+/.test(e.trim())){var h="+"==e.match(/\s*[-+]/)[0].trim();if(k==c+1){var i={type:"ul",listStyleType:h?"decimal":b[k%b.length],children:[]};return r(i,function(){g(c+1)}),void g(c)}if(k==c)return r({type:"li",children:[]},function(){c(e.replace(/\s*[-+]\s*/,""))}),j=j.slice(e.length),void g(c);if(k<c)return}var l=p.children[p.children.length-1];r(l,function(){c(e)},{isPush:!1}),j=j.slice(e.length),g(c)}}var j=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";j="".concat(j,"\n");var b=["disc","circle","square"];g()}function g(){if(!/^\n{1,2}$/.test(o)&&o){if(/Reg.br/.test(o)){var c=o.match(J.br),e=_slicedToArray(c,1),f=e[0];return p.children.push({type:"br"}),a(f),void g()}if(J.head.test(o)){var h=o.match(J.head)||[],i=_slicedToArray(h,3),j=i[0],l=i[1],m=i[2],q={type:"h".concat(l.length),children:[]};return r(q,function(){k(m)}),a(j),void g()}if(J.queto.test(o)){var t=o.match(J.queto),K=_slicedToArray(t,2),L=K[0],M=K[1],v=s(M,"[","]"),D=_slicedToArray(v,2),E=D[0],N=D[1],O={type:"queto",tag:E,children:[]},P=x(N.replace(/^\s*\n/,""));return O.children=P.children,p.children.push(O),p.children.push({type:"br"}),a(L),void g()}if(J.code.test(o)){var w=o.match(J.code),Q=_slicedToArray(w,2),R=Q[0],S=Q[1],T=b(S,"\n").map(function(b){return b.trim()}),u=_slicedToArray(T,2),W=u[0],y=u[1];return p.children.push({type:"code",language:W,value:y}),a(R),void g()}if(J.ul.test(o)){var U=o.match(J.ul),z=_slicedToArray(U,2),A=z[0],B=z[1];return r(p,function(){d(B)},{isPush:!1}),p.children.push({type:"br"}),a(A),void g()}if(o.match(/.+\n/)&&/\|.+\|/.test(o.match(/.+\n/)[0].trim())&&n(o))return void g();if(J.hr.test(o)){var C=o.match(J.hr)||[],V=_slicedToArray(C,1),X=V[0];return void 0!==X&&p.children.push({type:"hr",children:[]}),a(X),void g()}if(J.text.test(o)){var F=o.match(J.text)||[""],G=_slicedToArray(F,1),H=G[0];return k(H),a(H),void g()}throw new Error("cannot handle str:".concat(o))}}var o=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";o+="\n\n";var p={children:[],type:"root"};return g(),p}function a(c,a){return a&&a.parentElement&&a.parentElement.insertBefore(c,a),c}function j(o){var d=1<arguments.length&&void 0!==arguments[1]?arguments[1]:document.body;if(o){var e=o.nextNode;switch(o.type){case"del":{var f=o.prevNode.__htmlNode;f.parentElement||console.log("delete error::",o),f.parentElement.removeChild(f);break}case"add":{r(e,d,{beforeAppend:function(e){var b=d.childNodes[o.moveTo];if(b)return a(e,b),!0}});break}case"replace":{var b=o.prevNode.__htmlNode,c=document.createDocumentFragment();r(e,c),b.parentElement.replaceChild(c,b);break}case"move":{var k=o.moveTo,l=o.prevNode,g=l.__htmlNode.parentElement;g.childNodes[k]!==l.__htmlNode&&(g.childNodes[k]?a(l.__htmlNode,g.childNodes[k]):g.appendChild(l.__htmlNode));break}case"update":{var h=o.propsChange,p=o.children,i=o.prevNode,q=o.nextNode,m=i.__htmlNode;q.__htmlNode=m,i.__update&&(q.__update=i.__update),h.forEach(function(a){var b=a.key;switch(a.type){case"change":case"add":{var c=q[b];if(i.__update){i.__update(b,q);break}if(m instanceof Text){m.data=c;break}m.setAttribute(b,c);break}case"del":{m.removeAttribute(b);break}}}),p.forEach(function(a){return j(a,m)});break}default:console.error("canot handle type",o,o.type);}}}function t(a){var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";return"text"===a.type&&(c+=a.value||""),a.children&&a.children.forEach(function(a){c+=t(a)}),c}function r(c,e){var f,b=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};switch(c.type){case"audio":case"video":{if(/^<iframe(\s*.+)*><\/iframe>$/.test(c.src.trim())){f=document.createElement("div"),f.className="audio",f.innerHTML=c.src.replace("http://","//");var k=f.querySelector("iframe");k.style.cssText+=";max-width: 100%; max-height: 60vw; overflow: hidden;"}else f=document.createElement(c.type),f.src=c.src,f.alt=c.alt,f.controls="true";break}case"img":{var m=c.src.match(/\.(\d+)x(\d+)\./);if(m){var n=m.slice(1,3),g=_slicedToArray(n,2),l=g[0],a=g[1],i=c.src;f=document.createElement("div"),f.style.cssText=";position: relative; max-width: ".concat(l,"px; overflow: hidden; background: rgb(219, 221, 215);"),f.innerHTML="<div style=\"padding-top: ".concat(100*(a/l),"%;\">\n <img ").concat(LY.lazyLoad.caches.includes(i)?"src=\"".concat(i,"\" data-img-cache=\"true\""):"","\n class=\"lazy-load-img img-loading\"\n data-lazy-img=\"").concat(c.src,"\"\n style=\"position: absolute; width: 100%; height: 100%; top: 0;\" />\n </div>");break}else{f=document.createElement(c.type),f.src=c.src,f.alt=c.alt;break}}case"text":{var o=c.value;f=document.createTextNode(o);break}case"br":{f=document.createElement(c.type);break}case"a":{f=document.createElement(c.type),f.href=c.href,f.target="_blank";break}case"code":{f=document.createElement("pre");var j=document.createElement("code");c.__update=function(c,a){switch(c){case"language":{j.className=["highlight",a[c]||""].join(" ");break}case"value":{j.textContent=a[c];break}default:}},c.__update("language",c),c.__update("value",c),f.appendChild(j);break}case"inlineCode":{f=document.createElement("code"),f.className="inlineCode";break}case"h1":{f=document.createElement(c.type);var p=document.createElement("a"),q=t(c);p.href="#".concat(q),p.id=q,f.appendChild(p);break}case"ul":{f=document.createElement(c.type),c.__update=function(a,b){f.style.cssText+=";list-style-type:".concat(b[a],";")},c.__update("listStyleType",c);break}default:f=document.createElement(c.type),c.indent&&(f.style.cssText+=";padding-left: 2em;"),"table"==c.type&&f.setAttribute("border","1");}c.tag&&f.setAttribute("tag",c.tag),c.children&&c.children.forEach(function(b){return r(b,f)});var d=b.beforeAppend&&b.beforeAppend(f);return d||e.appendChild(f),c.__htmlNode=f,f}function u(b){function e(b){"text"==b.type&&(c+=b.value||""),"img"==b.type&&g.push(b.src),b.children&&b.children.forEach(e)}var c="",g=[];return e(b),{text:c,imgs:g}}function f(){var d=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",a=c[d];if(!a){var e=x(d);a=_objectSpread({root:e},u(e)),c[d]=a}return a}function e(f){return new Promise(function(a){if(g[f])return a();var b=function(){g[f]=!0,a()};if(f.endsWith(".js")){var c=document.createElement("script");c.onload=b,c.src=f,document.head.appendChild(c)}else if(f.endsWith(".css")){var d=document.createElement("link");d.onload=b,d.type="text/css",d.rel="stylesheet",d.charset="utf-8",d.href=f,document.head.appendChild(d)}})}function k(c,a){Promise.all(a.asset.map(e)).then(function(){window.hljs&&c&&(window.hljs.configure({tabReplace:4}),_toConsumableArray(c.querySelectorAll("code.highlight")).forEach(function(b){window.hljs.highlightBlock(b)}))})}function l(b){return _objectSpread({asset:[]},b)}var J={get hr(){return /(^-{3,}[^\n]+\n?)/},get code(){return /^`{3}(((?!```)[\s\S])*)`{3}/},get queto(){return /^>(((?!\n\n)[\s\S])*)\n\n/},get head(){return /^\s*(#{1,6})([^\n]*)\n?/},get ul(){return /^([-+]\s+((?!\n\n)[\s\S])*)\n\n/},get url(){return /^\[([^\]]+)\]\(([^)]+)\)/},get inlineCode(){return /^`([^`]*)`/},get br(){return /^\n/},get text(){return /^[^\n]*\n?/},get blod(){return /^\*{3}(((?!\*{3}).)*)\*{3}/},get italic(){return /^\*{2}(((?!\*{2}).)*)\*{2}/},get video(){return /^!{3}\[([^\]]*)\]\(([^)]+)\)/},get audio(){return /^!{2}\[([^\]]*)\]\(([^)]+)\)/},get img(){return /^!\[([^\]]*)\]\(([^)]+)\)/}},c={},g={},d=function(){function c(b,d){_classCallCheck(this,c),this.dom=b,this.config=d,this.prevRoot=null}return _createClass(c,[{key:"update",value:function(c){this.dom.classList.add("markdown");var e=f(c),a=o(this.prevRoot,e.root);this.prevRoot=e.root,j(a,this.dom);var d=l(this.config);d.useHighlight&&k(this.dom,d)}}]),c}();return i.Markdown=d,i.parser=x,i.trans=r,i.codeHighlight=k,i.getParseResult=f,i.markdown=function(b,a,d){b.innerHTML="",b.classList.add("markdown");var g=f(a);r(g.root,b),d=l(d),k(b,d)},i.markdownInfo=function(c){var d=f(c),a=d.root,e=_objectWithoutProperties(d,["root"]);return e},i}({});
{
"name": "lys-markdown-parser",
"version": "3.9.1",
"version": "3.10.0",
"description": "js markdown parser",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -96,3 +96,3 @@ import {

};
} else if (helper.nextIsLienEnd(tokens, index)) {
} else if (helper.nextIsLineEnd(tokens, index)) {
this.content.push(tokens[index], tokens[index + 1]);

@@ -99,0 +99,0 @@ // debugger

@@ -19,3 +19,3 @@ import nodeType, { TOKEN_TYPE as TKS } from '../nodeType.js';

};
while (offset < tokens.length) {
while (offset <= tokens.length) {
const item = tokens[offset];

@@ -80,3 +80,3 @@ // 如果匹配成功,会向后加+1

// 判断下一个字符是不是行尾
nextIsLienEnd(tokens, index) {
nextIsLineEnd(tokens, index) {
const token = tokens[index + 1];

@@ -152,2 +152,3 @@ return token && token.type === TKS.LINE_END;

if (!item) {
queueTypeIndex += 1;
break;

@@ -154,0 +155,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc