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

remark-custom-blocks

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-custom-blocks - npm Package Compare versions

Comparing version 2.3.2 to 2.3.3

75

dist/index.js

@@ -1,7 +0,19 @@

'use strict';
"use strict";
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
var spaceSeparated = require('space-separated-tokens');

@@ -17,5 +29,4 @@

function compilerFactory(nodeType) {
var text = void 0;
var title = void 0;
var text;
var title;
return {

@@ -36,6 +47,7 @@ blockHeading: function blockHeading(node) {

this.all(node);
if (title) {
return '[[' + nodeType + ' | ' + title + ']]\n| ' + text;
return "[[".concat(nodeType, " | ").concat(title, "]]\n| ").concat(text);
} else {
return '[[' + nodeType + ']]\n| ' + text;
return "[[".concat(nodeType, "]]\n| ").concat(text);
}

@@ -48,3 +60,2 @@ }

var availableBlocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var pattern = Object.keys(availableBlocks).map(escapeRegExp).join('|');

@@ -56,3 +67,3 @@

var regex = new RegExp('\\[\\[(' + pattern + ')(?: *\\| *(.*))?\\]\\]\n');
var regex = new RegExp("\\[\\[(".concat(pattern, ")(?: *\\| *(.*))?\\]\\]\n"));

@@ -69,3 +80,2 @@ function blockTokenizer(eat, value, silent) {

blockTitle = _keep[2];
/* istanbul ignore if - never used (yet) */

@@ -75,14 +85,13 @@

if (silent) return true;
var linesToEat = [];
var content = [];
var idx = 0;
var idx = 0;
while ((idx = value.indexOf(C_NEWLINE)) !== -1) {
var next = value.indexOf(C_NEWLINE, idx + 1);
// either slice until next NEWLINE or slice until end of string
var next = value.indexOf(C_NEWLINE, idx + 1); // either slice until next NEWLINE or slice until end of string
var lineToEat = next !== -1 ? value.slice(idx + 1, next) : value.slice(idx + 1);
if (lineToEat[0] !== C_FENCE) break;
// remove leading `FENCE ` or leading `FENCE`
var line = lineToEat.slice(lineToEat.startsWith(C_FENCE + ' ') ? 2 : 1);
if (lineToEat[0] !== C_FENCE) break; // remove leading `FENCE ` or leading `FENCE`
var line = lineToEat.slice(lineToEat.startsWith("".concat(C_FENCE, " ")) ? 2 : 1);
linesToEat.push(lineToEat);

@@ -94,17 +103,12 @@ content.push(line);

var contentString = content.join(C_NEWLINE);
var stringToEat = eaten + linesToEat.join(C_NEWLINE);
var potentialBlock = availableBlocks[blockType];
var titleAllowed = potentialBlock.title && ['optional', 'required'].includes(potentialBlock.title);
var titleRequired = potentialBlock.title && potentialBlock.title === 'required';
if (titleRequired && !blockTitle) return;
if (!titleAllowed && blockTitle) return;
var add = eat(stringToEat);
var exit = this.enterBlock();
var contents = {
type: blockType + 'CustomBlockBody',
type: "".concat(blockType, "CustomBlockBody"),
data: {

@@ -119,7 +123,7 @@ hName: 'div',

exit();
var blockChildren = [contents];
var blockChildren = [contents];
if (titleAllowed && blockTitle) {
var titleNode = {
type: blockType + 'CustomBlockHeading',
type: "".concat(blockType, "CustomBlockHeading"),
data: {

@@ -133,3 +137,2 @@ hName: potentialBlock.details ? 'summary' : 'div',

};
blockChildren.unshift(titleNode);

@@ -139,5 +142,4 @@ }

var classList = spaceSeparated.parse(potentialBlock.classes || '');
return add({
type: blockType + 'CustomBlock',
type: "".concat(blockType, "CustomBlock"),
children: blockChildren,

@@ -153,5 +155,4 @@ data: {

var Parser = this.Parser;
var Parser = this.Parser; // Inject blockTokenizer
// Inject blockTokenizer
var blockTokenizers = Parser.prototype.blockTokenizers;

@@ -162,2 +163,3 @@ var blockMethods = Parser.prototype.blockMethods;

var Compiler = this.Compiler;
if (Compiler) {

@@ -168,8 +170,9 @@ var visitors = Compiler.prototype.visitors;

var compiler = compilerFactory(key);
visitors[key + 'CustomBlock'] = compiler.block;
visitors[key + 'CustomBlockHeading'] = compiler.blockHeading;
visitors[key + 'CustomBlockBody'] = compiler.blockBody;
visitors["".concat(key, "CustomBlock")] = compiler.block;
visitors["".concat(key, "CustomBlockHeading")] = compiler.blockHeading;
visitors["".concat(key, "CustomBlockBody")] = compiler.blockBody;
});
}
// Inject into interrupt rules
} // Inject into interrupt rules
var interruptParagraph = Parser.prototype.interruptParagraph;

@@ -176,0 +179,0 @@ var interruptList = Parser.prototype.interruptList;

{
"name": "remark-custom-blocks",
"version": "2.3.2",
"version": "2.3.3",
"repository": {

@@ -37,3 +37,3 @@ "url": "https://github.com/zestedesavoir/zmarkdown/tree/master/packages/remark-custom-blocks",

},
"gitHead": "1dded309a2670689a4a3353f9e38b80624c6df1a"
"gitHead": "7b61723ac4ca1900270d56c7787c08b6887fcb4c"
}
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