Skip to content

Commit 19155e2

Browse files
committed
Update heading ID computation
1 parent 7a7f2e2 commit 19155e2

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Markdown code is now stripped out of TOC names
55
- The first page will always be the home page
66
- You can now link Table of Contents as part of the site
7+
- Make heading ID's match what GitHub expects
78

89
## [v0.2.0]
910
> Oct 12, 2015

lib/slugify.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ module.exports = function slugify (str) {
1515
str = str.replace(/\/index.html$/, '')
1616
str = str.replace(/.html$/, '')
1717
str = parameterize(str)
18+
str = str.replace(/[^a-zA-Z0-9\-_]/g, '')
1819
if (str.length) return str
1920
}

test/slugify_test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,11 @@ describe('slugify', function () {
1414
test('usage.html', 'usage')
1515
test('/foo/index.html', 'foo')
1616
test('index.html', 'index')
17+
test('page(callback)', 'pagecallback')
18+
test('page(path, callback[, callback ...])', 'pagepath-callback-callback-')
19+
test('context#save', 'contextsave')
20+
test('404 behavior', '404-behavior')
21+
test('IE8+', 'ie8')
22+
test('Hi (optional):', 'hi-optional')
23+
test('a b c', 'a-b-c')
1724
})

0 commit comments

Comments
 (0)