Skip to content

Commit

Permalink
Update dev-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Apr 25, 2021
1 parent 49bb245 commit b053134
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 35 deletions.
2 changes: 1 addition & 1 deletion lib/contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = contents
// Transform a list of heading objects to a markdown list.
function contents(map, tight, prefix, ordered) {
var table = {type: 'list', ordered: ordered, spread: false, children: []}
var minDepth = Infinity
var minDepth = Number.POSITIVE_INFINITY
var index = -1

// Find minimum depth.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"typescript": "^4.0.0",
"unified": "^9.0.0",
"unist-builder": "^2.0.0",
"xo": "^0.34.0"
"xo": "^0.38.0"
},
"scripts": {
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
Expand Down
71 changes: 38 additions & 33 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,44 @@ test('mdast-util-toc', function (t) {

test('Fixtures', function (t) {
var root = join(__dirname, 'fixtures')

fs.readdirSync(root)
.filter(function (filepath) {
return filepath.indexOf('.') !== 0
})
.forEach(function (name) {
var input = fs.readFileSync(join(root, name, 'input.md'))
var output = fs.readFileSync(join(root, name, 'output.json'))
var config = {}
var expected = JSON.parse(output)
var actual
var processor = unified()

try {
config = JSON.parse(fs.readFileSync(join(root, name, 'config.json')))
} catch (_) {}

processor.use(remarkParse).use(remarkGfm)

if (config.useRemarkFootnotes) {
processor.use(remarkFootnotes, {inlineNotes: true})
}

if (config.useRemarkAttr) {
// To do: add remark attr back when it’s updated for the new parser.
// `processor.use(remarkAttr)`
return
}

actual = toc(processor.parse(input), config)

t.deepEqual(actual, expected, name)
})
var files = fs.readdirSync(root)
var index = -1
var name
var input
var expected
var actual
var config
var processor

while (++index < files.length) {
name = files[index]

if (name.indexOf('.') === 0) continue

input = fs.readFileSync(join(root, name, 'input.md'))
expected = JSON.parse(fs.readFileSync(join(root, name, 'output.json')))
processor = unified().use(remarkParse).use(remarkGfm)

try {
config = JSON.parse(fs.readFileSync(join(root, name, 'config.json')))
} catch (_) {
config = {}
}

if (config.useRemarkFootnotes) {
processor.use(remarkFootnotes, {inlineNotes: true})
}

if (config.useRemarkAttr) {
// To do: add remark attr back when it’s updated for the new parser.
// `processor.use(remarkAttr)`
continue
}

actual = toc(processor.parse(input), config)

t.deepEqual(actual, expected, name)
}

t.end()
})
Expand Down

0 comments on commit b053134

Please sign in to comment.