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

down-parse

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

down-parse - npm Package Compare versions

Comparing version 2.1.9 to 2.2.0

2

dist/main.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var PluginCtx=function(){var n=this;this.renders=[],this.parsers=[],this.use=function(e){var t=e.parser,r=e.render;t&&n.parsers.push(t),r&&n.renders.push(r)},this.applyParses=function(e,r){return n.parsers.reduce(function(e,t){return t(e,r)},e)},this.applyRenders=function(r,e){return n.renders.reduce(function(e,t){return t(r,e)},e)}},ctx=new PluginCtx,use=ctx.use;function createPlugin(e){return e}function getTokenFrom(e){for(var t=[],r=0;r<e.length;r++){var n=e[r],i=void 0;if(n.startsWith("#")){var s=n.split("#"),o=s.pop();o||(o=""),i={type:"#",weight:s.length,text:o.trim(),origin:n}}else if(n.startsWith("---")||n.startsWith("***"))i={type:"hr",origin:n};else if(/^[>-]|\* /.test(n)||/^[0-9]. /.test(n)){var p=n.split(""),l=p[0],a=p.slice(1);if(Number.isNaN(+l))"-"===l&&(l="*"),i={type:l,inner:getTokenFrom([a.slice(1).join("")])[0],n:0,origin:n};else i={type:0,n:+l,inner:getTokenFrom([a.slice(2).join("")])[0],origin:n}}else if(n.startsWith("```")){var u=n.split(" ").slice(1),c=e.slice(r+1),f=c.findIndex(function(e){return"```"===e});r=r+f+1,i={type:"</>",params:u,code:c.slice(0,f).join("\n"),origin:n}}else i=""===n?{type:"br",origin:n}:{type:"p",text:n,origin:n};console.log(i),t.push(ctx.applyParses(i,n))}return t}function map2lines(e){return e.split("\n").map(function(e){return e.trim()})}function parse(e){return getTokenFrom(map2lines(e))}function fold(e){var t=e[0],r=e.slice(1);if(void 0===t)return[];if("br"===t.type||"#"===t.type||"</>"===t.type||"p"===t.type||"hr"===t.type)return[t].concat(fold(r));for(var n=[],i=0;i<r.length;i++){var s=r[i];if(t.type!==s.type)break;n.push(s)}return[{type:t.type,block:fold([t].concat(n).map(function(e){return e.inner}))}].concat(fold(r.slice(n.length)))}function compile(e){return fold(parse(e))}function astEval(e){return e.reduce(function(e,t){var r;if("p"===t.type)r="<p>"+t.text+"</p>";else if("br"===t.type)r="<br />";else if("#"===t.type){var n=t.weight;r="<h"+n+">"+t.text+"</h"+n+">"}else if("</>"===t.type)r='<pre><code class="'+t.params.join(" ")+'">'+t.code+"</code></pre>";else if(0===t.type){var i=astEval(t.block);r='<ol type="'+t.type+'">'+i+"</ol>"}else if("hr"===t.type)r="<hr />";else{i=astEval(t.block);r='<ul type="'+t.type+'">'+i+"</ul>"}return e+ctx.applyRenders(t,r)},"")}function render(e){return astEval(compile(e))}exports.fold=fold,exports.compile=compile,exports.astEval=astEval,exports.render=render,exports.getTokenFrom=getTokenFrom,exports.parse=parse,exports.PluginCtx=PluginCtx,exports.ctx=ctx,exports.use=use,exports.createPlugin=createPlugin;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var PluginCtx=function(){var n=this;this.renders=[],this.parsers=[],this.use=function(e){var t=e.parser,r=e.render;t&&n.parsers.push(t),r&&n.renders.push(r)},this.applyParses=function(e,r){return n.parsers.reduce(function(e,t){return t(e,r)},e)},this.applyRenders=function(r,e){return n.renders.reduce(function(e,t){return t(r,e)},e)}},ctx=new PluginCtx,use=ctx.use;function createPlugin(e){return e}function getTokenFrom(e){for(var t=[],r=0;r<e.length;r++){var n=e[r],i=void 0;if(n.startsWith("#")){var s=n.split("#"),o=s.pop();o||(o=""),i={type:"#",weight:s.length,text:o.trim(),origin:n}}else if(n.startsWith("---")||n.startsWith("***"))i={type:"hr",origin:n};else if(/^[>-]|\* /.test(n)||/^[0-9]. /.test(n)){var p=n.split(""),l=p[0],a=p.slice(1);if(Number.isNaN(+l))"-"===l&&(l="*"),i={type:l,inner:getTokenFrom([a.slice(1).join("")])[0],n:0,origin:n};else i={type:0,n:+l,inner:getTokenFrom([a.slice(2).join("")])[0],origin:n}}else if(n.startsWith("```")){var u=n.split(" ").slice(1),c=e.slice(r+1),f=c.findIndex(function(e){return"```"===e});r=r+f+1,i={type:"</>",params:u,code:c.slice(0,f).join("\n"),origin:n}}else i=""===n?{type:"br",origin:n}:{type:"p",text:n,origin:n};t.push(ctx.applyParses(i,n))}return t}function map2lines(e){return e.split("\n").map(function(e){return e.trim()})}function parse(e){return getTokenFrom(map2lines(e))}function fold(e){var t=e[0],r=e.slice(1);if(void 0===t)return[];if("br"===t.type||"#"===t.type||"</>"===t.type||"p"===t.type||"hr"===t.type)return[t].concat(fold(r));for(var n=[],i=0;i<r.length;i++){var s=r[i];if(t.type!==s.type)break;n.push(s)}return[{type:t.type,block:fold([t].concat(n).map(function(e){return e.inner}))}].concat(fold(r.slice(n.length)))}function compile(e){return fold(parse(e))}function astEval(e){return e.reduce(function(e,t){var r;if("p"===t.type)r="<p>"+t.text+"</p>";else if("br"===t.type)r="<br />";else if("#"===t.type){var n=t.weight;r="<h"+n+">"+t.text+"</h"+n+">"}else if("</>"===t.type)r='<pre><code class="'+t.params.join(" ")+'">'+t.code+"</code></pre>";else if(0===t.type){var i=astEval(t.block);r='<ol type="'+t.type+'">'+i+"</ol>"}else if("hr"===t.type)r="<hr />";else{i=astEval(t.block);r='<ul type="'+t.type+'">'+i+"</ul>"}return e+ctx.applyRenders(t,r)},"")}function render(e){return astEval(compile(e))}exports.fold=fold,exports.compile=compile,exports.astEval=astEval,exports.render=render,exports.getTokenFrom=getTokenFrom,exports.parse=parse,exports.PluginCtx=PluginCtx,exports.ctx=ctx,exports.use=use,exports.createPlugin=createPlugin;

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.DownParse={})}(this,function(e){"use strict";var t=function(){var n=this;this.renders=[],this.parsers=[],this.use=function(e){var t=e.parser,r=e.render;t&&n.parsers.push(t),r&&n.renders.push(r)},this.applyParses=function(e,r){return n.parsers.reduce(function(e,t){return t(e,r)},e)},this.applyRenders=function(r,e){return n.renders.reduce(function(e,t){return t(r,e)},e)}},y=new t,r=y.use;function d(e){for(var t=[],r=0;r<e.length;r++){var n=e[r],i=void 0;if(n.startsWith("#")){var s=n.split("#"),p=s.pop();p||(p=""),i={type:"#",weight:s.length,text:p.trim(),origin:n}}else if(n.startsWith("---")||n.startsWith("***"))i={type:"hr",origin:n};else if(/^[>-]|\* /.test(n)||/^[0-9]. /.test(n)){var o=n.split(""),u=o[0],c=o.slice(1);if(Number.isNaN(+u))"-"===u&&(u="*"),i={type:u,inner:d([c.slice(1).join("")])[0],n:0,origin:n};else i={type:0,n:+u,inner:d([c.slice(2).join("")])[0],origin:n}}else if(n.startsWith("```")){var l=n.split(" ").slice(1),a=e.slice(r+1),f=a.findIndex(function(e){return"```"===e});r=r+f+1,i={type:"</>",params:l,code:a.slice(0,f).join("\n"),origin:n}}else i=""===n?{type:"br",origin:n}:{type:"p",text:n,origin:n};console.log(i),t.push(y.applyParses(i,n))}return t}function n(e){return d(e.split("\n").map(function(e){return e.trim()}))}function p(e){var t=e[0],r=e.slice(1);if(void 0===t)return[];if("br"===t.type||"#"===t.type||"</>"===t.type||"p"===t.type||"hr"===t.type)return[t].concat(p(r));for(var n=[],i=0;i<r.length;i++){var s=r[i];if(t.type!==s.type)break;n.push(s)}return[{type:t.type,block:p([t].concat(n).map(function(e){return e.inner}))}].concat(p(r.slice(n.length)))}function i(e){return p(n(e))}function s(e){return e.reduce(function(e,t){var r;if("p"===t.type)r="<p>"+t.text+"</p>";else if("br"===t.type)r="<br />";else if("#"===t.type){var n=t.weight;r="<h"+n+">"+t.text+"</h"+n+">"}else if("</>"===t.type)r='<pre><code class="'+t.params.join(" ")+'">'+t.code+"</code></pre>";else if(0===t.type){var i=s(t.block);r='<ol type="'+t.type+'">'+i+"</ol>"}else if("hr"===t.type)r="<hr />";else{i=s(t.block);r='<ul type="'+t.type+'">'+i+"</ul>"}return e+y.applyRenders(t,r)},"")}e.fold=p,e.compile=i,e.astEval=s,e.render=function(e){return s(i(e))},e.getTokenFrom=d,e.parse=n,e.PluginCtx=t,e.ctx=y,e.use=r,e.createPlugin=function(e){return e},Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.DownParse={})}(this,function(e){"use strict";var t=function(){var n=this;this.renders=[],this.parsers=[],this.use=function(e){var t=e.parser,r=e.render;t&&n.parsers.push(t),r&&n.renders.push(r)},this.applyParses=function(e,r){return n.parsers.reduce(function(e,t){return t(e,r)},e)},this.applyRenders=function(r,e){return n.renders.reduce(function(e,t){return t(r,e)},e)}},y=new t,r=y.use;function d(e){for(var t=[],r=0;r<e.length;r++){var n=e[r],i=void 0;if(n.startsWith("#")){var s=n.split("#"),p=s.pop();p||(p=""),i={type:"#",weight:s.length,text:p.trim(),origin:n}}else if(n.startsWith("---")||n.startsWith("***"))i={type:"hr",origin:n};else if(/^[>-]|\* /.test(n)||/^[0-9]. /.test(n)){var o=n.split(""),u=o[0],c=o.slice(1);if(Number.isNaN(+u))"-"===u&&(u="*"),i={type:u,inner:d([c.slice(1).join("")])[0],n:0,origin:n};else i={type:0,n:+u,inner:d([c.slice(2).join("")])[0],origin:n}}else if(n.startsWith("```")){var a=n.split(" ").slice(1),l=e.slice(r+1),f=l.findIndex(function(e){return"```"===e});r=r+f+1,i={type:"</>",params:a,code:l.slice(0,f).join("\n"),origin:n}}else i=""===n?{type:"br",origin:n}:{type:"p",text:n,origin:n};t.push(y.applyParses(i,n))}return t}function n(e){return d(e.split("\n").map(function(e){return e.trim()}))}function p(e){var t=e[0],r=e.slice(1);if(void 0===t)return[];if("br"===t.type||"#"===t.type||"</>"===t.type||"p"===t.type||"hr"===t.type)return[t].concat(p(r));for(var n=[],i=0;i<r.length;i++){var s=r[i];if(t.type!==s.type)break;n.push(s)}return[{type:t.type,block:p([t].concat(n).map(function(e){return e.inner}))}].concat(p(r.slice(n.length)))}function i(e){return p(n(e))}function s(e){return e.reduce(function(e,t){var r;if("p"===t.type)r="<p>"+t.text+"</p>";else if("br"===t.type)r="<br />";else if("#"===t.type){var n=t.weight;r="<h"+n+">"+t.text+"</h"+n+">"}else if("</>"===t.type)r='<pre><code class="'+t.params.join(" ")+'">'+t.code+"</code></pre>";else if(0===t.type){var i=s(t.block);r='<ol type="'+t.type+'">'+i+"</ol>"}else if("hr"===t.type)r="<hr />";else{i=s(t.block);r='<ul type="'+t.type+'">'+i+"</ul>"}return e+y.applyRenders(t,r)},"")}e.fold=p,e.compile=i,e.astEval=s,e.render=function(e){return s(i(e))},e.getTokenFrom=d,e.parse=n,e.PluginCtx=t,e.ctx=y,e.use=r,e.createPlugin=function(e){return e},Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "down-parse",
"version": "2.1.9",
"version": "2.2.0",
"description": "markdown parser",

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

@@ -105,4 +105,2 @@ import { ctx } from "./plugin";

console.log(ret);
tokens.push(ctx.applyParses(ret, lineOne));

@@ -109,0 +107,0 @@ }

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