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

remark-abbr

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-abbr - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

21

dist/index.js

@@ -41,7 +41,16 @@ 'use strict';

var abbrs = {};
visit(tree, 'paragraph', find(abbrs));
var emptyParagraphsToRemove = new Map();
visit(tree, 'paragraph', find(abbrs, emptyParagraphsToRemove));
emptyParagraphsToRemove.forEach(function (indices, key) {
indices.reverse();
indices.forEach(function (index) {
key.children.splice(index, 1);
});
});
visit(tree, replace(abbrs));
}
function find(abbrs) {
function find(abbrs, emptyParagraphsToRemove) {
return function one(node, index, parent) {

@@ -56,4 +65,8 @@ for (var i = 0; i < node.children.length; i++) {

}
// Remove paragraph if there is no child
if (node.children.length === 0) parent.children.splice(index, 1);
// Keep track of empty paragraphs to remove
if (node.children.length === 0) {
var indices = emptyParagraphsToRemove.get(parent) || [];
indices.push(index);
emptyParagraphsToRemove.set(parent, indices);
}
};

@@ -60,0 +73,0 @@ }

4

package.json
{
"name": "remark-abbr",
"version": "1.2.2",
"version": "1.2.3",
"repository": {

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

},
"gitHead": "bfff52b7e7a248004b81525f54354f1acceba898"
"gitHead": "47164411c9e3ae0d7d29ebb7ab0d112569e83f01"
}

@@ -36,7 +36,16 @@ const visit = require('unist-util-visit')

const abbrs = {}
visit(tree, 'paragraph', find(abbrs))
const emptyParagraphsToRemove = new Map()
visit(tree, 'paragraph', find(abbrs, emptyParagraphsToRemove))
emptyParagraphsToRemove.forEach((indices, key) => {
indices.reverse()
indices.forEach((index) => {
key.children.splice(index, 1)
})
})
visit(tree, replace(abbrs))
}
function find (abbrs) {
function find (abbrs, emptyParagraphsToRemove) {
return function one (node, index, parent) {

@@ -51,4 +60,8 @@ for (let i = 0; i < node.children.length; i++) {

}
// Remove paragraph if there is no child
if (node.children.length === 0) parent.children.splice(index, 1)
// Keep track of empty paragraphs to remove
if (node.children.length === 0) {
const indices = emptyParagraphsToRemove.get(parent) || []
indices.push(index)
emptyParagraphsToRemove.set(parent, indices)
}
}

@@ -55,0 +68,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