Comparing version 0.1.0 to 0.2.0
@@ -28,4 +28,7 @@ /* | ||
s = entities.decode(s); | ||
s = s.replace(/['"]/g, ''); | ||
s = s.replace(/['"!]|[\.]+$/g, ''); | ||
s = slug(s); | ||
s = s.replace(/[:\(\)]+/gi, '-'); | ||
s = s.replace(/[\s\-]*([\.])[\s\-]*/g, '$1'); | ||
s = s.replace(/-+/g, '-'); | ||
s = s.replace(/^-+|-+$/g, ''); | ||
@@ -93,17 +96,18 @@ return s; | ||
level = Number(level); | ||
var data = { | ||
level: level, | ||
attrs: attrs, | ||
header: header, | ||
text: options.untag(header), | ||
anchor: options.unique(names, options.anchor(header)), | ||
}; | ||
if (level >= options.tocMin && level <= options.tocMax) { | ||
var tocLevel = level >= options.tocMin && level <= options.tocMax; | ||
var anchorLevel = level >= options.anchorMin && level <= options.anchorMax; | ||
var data; | ||
if (tocLevel || anchorLevel) { | ||
data = { | ||
level: level, | ||
attrs: attrs, | ||
header: header, | ||
text: options.untag(header), | ||
anchor: options.unique(names, options.anchor(header)), | ||
}; | ||
} | ||
if (tocLevel) { | ||
datas.push(data); | ||
} | ||
if (level >= options.anchorMin && level <= options.anchorMax) { | ||
return options.header(data); | ||
} else { | ||
return all; | ||
} | ||
return anchorLevel ? options.header(data) : all; | ||
}); | ||
@@ -110,0 +114,0 @@ |
{ | ||
"name": "toc", | ||
"description": "Linkify HTML headers and generate a TOC.", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/cowboy/node-toc", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -62,3 +62,3 @@ # toc [![Build Status](https://secure.travis-ci.org/cowboy/node-toc.png?branch=master)](http://travis-ci.org/cowboy/node-toc) | ||
You can customize the hell out of the generated HTML, eg. | ||
The default HTML is pretty awesome, but you can customize the hell out of the generated HTML, eg. | ||
@@ -80,6 +80,3 @@ ```js | ||
## Release History | ||
2013-03-07 - v0.2.0 - Second official release. Minor changes. | ||
2013-03-07 - v0.1.0 - First official release. | ||
## License | ||
Copyright (c) 2013 "Cowboy" Ben Alman | ||
Licensed under the MIT license. |
@@ -44,3 +44,3 @@ 'use strict'; | ||
exports['anchor'] = function(test) { | ||
test.expect(8); | ||
test.expect(10); | ||
test.equal(toc.anchor('foo'), 'foo', 'anchor is already lovely.'); | ||
@@ -52,3 +52,5 @@ test.equal(toc.anchor('foo bar baz'), 'foo-bar-baz', 'spaces get converted to -'); | ||
test.equal(toc.anchor('i can\'t "go" for that'), 'i-cant-go-for-that', 'quotes get stripped'); | ||
test.equal(toc.anchor('obj.method(this, [that])'), 'obj.method(this-that)', 'some other chars get stripped, yay'); | ||
test.equal(toc.anchor('obj / obj.method(this, [that])'), 'obj-obj.method-this-that', 'some other chars get stripped, yay'); | ||
test.equal(toc.anchor('obj.method ( this, [ that ] )'), 'obj.method-this-that', 'remove unnecessary - chars'); | ||
test.equal(toc.anchor('this: that :: the other'), 'this-that-the-other', 'replace : with - chars'); | ||
test.equal(toc.anchor('фøó & βåρ ♥ Бäž'), 'foo-and-bar-love-baz', 'entities and utf characters should be made happy'); | ||
@@ -55,0 +57,0 @@ test.done(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16120
253
81