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.0 to 3.9.1

2

dist/index.umd.js

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

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

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

Sorry, the diff of this file is not supported yet

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