Comparing version 3.0.1 to 3.0.2
12
index.js
@@ -5,3 +5,2 @@ var fs = require('fs'); | ||
var cheerio = require('cheerio'); | ||
var normall = require('normall'); | ||
@@ -159,3 +158,3 @@ var rules = require('./rules'); | ||
var oldId = $(this).attr('id'); | ||
var textId = normall.filename($(this).text()); | ||
var textId = normalizeId($(this).text()); | ||
@@ -180,2 +179,11 @@ var newId = textId; | ||
// Normalize an id | ||
function normalizeId(id) { | ||
// Replace any non alpha-numeric character by an hyphen | ||
id = id.replace(/[^a-zA-Z\d]+/g, '-'); | ||
// Make lowercase | ||
id = id.toLowerCase(); | ||
return id; | ||
}; | ||
// For empty <a> tags with an id attribute, set id on parent | ||
@@ -182,0 +190,0 @@ function setAnchorsId() { |
{ | ||
"name": "brightml", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Smart utility rendering markdown-ready HTML", | ||
@@ -23,4 +23,3 @@ "main": "index.js", | ||
"cheerio": "git://github.com/cheeriojs/cheerio.git#70c5608113d3efaf584efd29edafe173b74e106f", | ||
"lodash": "^3.10.1", | ||
"normall": "^0.2.2" | ||
"lodash": "^3.10.1" | ||
}, | ||
@@ -27,0 +26,0 @@ "scripts": { |
@@ -220,7 +220,7 @@ var should = require('should'); | ||
var input = '<h1 id="345-is-a-weird-id">'+ | ||
'Sample title'+ | ||
'Complex_title 101&# Others'+ | ||
'</h1>'; | ||
var correctOutput = '<h1 id="sample_title">'+ | ||
'Sample title'+ | ||
var correctOutput = '<h1 id="complex-title-101-others">'+ | ||
'Complex_title 101&# Others'+ | ||
'</h1>'; | ||
@@ -243,6 +243,6 @@ | ||
var correctOutput = '<h2 id="a_great_title">'+ | ||
var correctOutput = '<h2 id="a-great-title">'+ | ||
'A great title'+ | ||
'</h2>'+ | ||
'<a href="#a_great_title">'+ | ||
'<a href="#a-great-title">'+ | ||
'Go back'+ | ||
@@ -455,3 +455,3 @@ '</a>'; | ||
var correctOutput = '<h1 id="part_1">Part 1</h1>'+ | ||
var correctOutput = '<h1 id="part-1">Part 1</h1>'+ | ||
'<p>'+ | ||
@@ -483,5 +483,5 @@ 'Sample footnote'+ | ||
'</p>'+ | ||
'<h1 id="part_2">Part 2</h1>'+ | ||
'<h1 id="part-2">Part 2</h1>'+ | ||
'<p>Some content</p>'+ | ||
'<h1 id="part_3">Part 3</h1>'+ | ||
'<h1 id="part-3">Part 3</h1>'+ | ||
'<caption>Data table</caption>'+ | ||
@@ -488,0 +488,0 @@ '<table>'+ |
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
32642
2
797
- Removednormall@^0.2.2
- Removedhan@0.0.7(transitive)
- Removedlatenize@0.2.0(transitive)
- Removednormall@0.2.2(transitive)