forked from thlorenz/doctoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: Crashes if a header is
hasOwnProperty
True story: <1-liners/1-liners@c087021>. Explain change in a comment Add test for weird headers Closes thlorenz#70
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
README to test doctoc with edge-case headers. | ||
|
||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
## Table of Contents | ||
|
||
- [hasOwnProperty](#hasownproperty) | ||
- [something else](#something-else) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
|
||
## hasOwnProperty | ||
## something else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
/*jshint asi: true */ | ||
|
||
var test = require('tap').test | ||
, transform = require('../lib/transform'); | ||
|
||
test('\ngiven a file with edge-case header names', function (t) { | ||
var content = require('fs').readFileSync(__dirname + '/fixtures/readme-with-weird-headers.md', 'utf8'); | ||
var headers = transform(content); | ||
|
||
t.deepEqual( | ||
headers.toc.split('\n') | ||
, [ '## Table of Contents', | ||
'', | ||
'- [hasOwnProperty](#hasownproperty)', | ||
'- [something else](#something-else)', | ||
'' ] | ||
, 'generates a correct toc when headers are weird' | ||
) | ||
|
||
t.end() | ||
}) |