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

mehdown

Package Overview
Dependencies
Maintainers
1
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mehdown - npm Package Compare versions

Comparing version 1.6.4 to 1.7.0

.jshintrc

14

lib/index.js

@@ -145,11 +145,21 @@ var Mehdown;

Mehdown.header = function(suffix) {
function toSlug(value) {
return value
.toLowerCase()
.replace(/[^\w ]+/g, '')
.replace(/ +/g, '-')
.replace(/^-*/, '')
.replace(/-*$/, '');
}
return function(header) {
var text = header.replace(/<h\d[^>]*>([^<]+)<\/h\d>/, '$1');
text = text.replace(/\s+/g, '-');
text = toSlug(text);
if (suffix) {
suffix = toSlug(suffix);
text = text + '-' + suffix;
}
return header.replace(/<h\d/, '$& id="' + text.toLowerCase() + '"');
return header.replace(/<h\d/, '$& id="' + text + '"');
};

@@ -156,0 +166,0 @@ };

2

package.json

@@ -13,3 +13,3 @@ {

},
"version": "1.6.4"
"version": "1.7.0"
}

@@ -71,2 +71,22 @@ var assert = require('assert');

});
it('handle header text with non alpha-numeric characters', function() {
var text = mehdown.parse('<h1>What.is!meh?</h1>', { suffix: '0.1!2?f..e!!d??' });
assert.equal(text, '<h1 id="whatismeh-012fed">What.is!meh?</h1>');
});
it('handle header text with multiple spaces', function() {
var text = mehdown.parse('<h1>What. is ! meh ?</h1>', { suffix: '0. 1! 2?f. . e! !d? ?' });
assert.equal(text, '<h1 id="what-is-meh-0-1-2f-e-d">What. is ! meh ?</h1>');
});
it('hanlde suffix with non alpha-numeric characters', function() {
var text = mehdown.parse('<h1>a- -b?c</h1>', { suffix: '!@#$%^&*()=+`~,./;\'<>?:"[]{}|' });
assert.equal(text, '<h1 id="a-bc-">a- -b?c</h1>');
});
it('collapse multiple hyphens', function() {
var text = mehdown.parse('<h1>-- - What - - is --- - - meh - - -</h1>', { suffix: '!@#$%^&*()=+`~,./;\'<>?:"[]{}|' });
assert.equal(text, '<h1 id="what-is-meh-">-- - What - - is --- - - meh - - -</h1>');
});
});

@@ -73,0 +93,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