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 15, 2024
1 parent 862e015 commit f2f0f62
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 49 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @returns {Array<Nodes> | Nodes | null | undefined}
* Result.
*
* @typedef {Partial<Record<Nodes['type'], Handler>>} Handlers
* @typedef {Partial<Record<Nodes['type'], Handler | undefined>>} Handlers
* Handlers.
*
* @typedef Options
Expand Down
14 changes: 3 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@
"devDependencies": {
"@types/node": "^20.0.0",
"@types/unist": "^3.0.0",
"c8": "^8.0.0",
"c8": "^9.0.0",
"prettier": "^3.0.0",
"remark": "^15.0.0",
"remark-cli": "^12.0.0",
"remark-directive": "^3.0.0",
"remark-gfm": "^4.0.0",
"remark-preset-wooorm": "^9.0.0",
"remark-preset-wooorm": "^10.0.0",
"type-coverage": "^2.0.0",
"typescript": "^5.0.0",
"xo": "^0.56.0"
"xo": "^0.58.0"
},
"scripts": {
"build": "tsc --build --clean && tsc --build && type-coverage",
Expand All @@ -69,14 +69,6 @@
"remarkConfig": {
"plugins": [
"remark-preset-wooorm",
[
"remark-lint-list-item-indent",
"space"
],
[
"remark-preset-wooorm/node_modules/remark-gfm/index.js",
false
],
"remark-gfm"
]
},
Expand Down
74 changes: 37 additions & 37 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,160 +57,160 @@ test('stripMarkdown', async function (t) {
})

await t.test('should support text', async function () {
assert.equal(await proc('Alfred'), 'Alfred\n')
assert.equal(await process('Alfred'), 'Alfred\n')
})

await t.test('should support emphasis (1)', async function () {
assert.equal(await proc('*Alfred*'), 'Alfred\n')
assert.equal(await process('*Alfred*'), 'Alfred\n')
})

await t.test('should support emphasis (2)', async function () {
assert.equal(await proc('_Alfred_'), 'Alfred\n')
assert.equal(await process('_Alfred_'), 'Alfred\n')
})

await t.test('should support strong (1)', async function () {
assert.equal(await proc('**Alfred**'), 'Alfred\n')
assert.equal(await process('**Alfred**'), 'Alfred\n')
})

await t.test('should support strong (2)', async function () {
assert.equal(await proc('__Alfred__'), 'Alfred\n')
assert.equal(await process('__Alfred__'), 'Alfred\n')
})

await t.test('should support strikethrough', async function () {
assert.equal(await proc('~~Alfred~~'), 'Alfred\n')
assert.equal(await process('~~Alfred~~'), 'Alfred\n')
})

await t.test('should support inline code', async function () {
assert.equal(await proc('`Alfred`'), 'Alfred\n')
assert.equal(await process('`Alfred`'), 'Alfred\n')
})

await t.test('should support a resource link', async function () {
assert.equal(await proc('[Hello](world)'), 'Hello\n')
assert.equal(await process('[Hello](world)'), 'Hello\n')
})

await t.test('should support strong in a link', async function () {
assert.equal(await proc('[**H**ello](world)'), 'Hello\n')
assert.equal(await process('[**H**ello](world)'), 'Hello\n')
})

await t.test('should support a reference/definition', async function () {
assert.equal(
await proc('[Hello][id]\n\n[id]: http://example.com "optional title"'),
await process('[Hello][id]\n\n[id]: http://example.com "optional title"'),
'Hello\n'
)
})

await t.test('should support a paragraph', async function () {
assert.equal(await proc('Hello.\n\nWorld.'), 'Hello.\n\nWorld.\n')
assert.equal(await process('Hello.\n\nWorld.'), 'Hello.\n\nWorld.\n')
})

await t.test('should support a heading (atx)', async function () {
assert.equal(await proc('## Alfred'), 'Alfred\n')
assert.equal(await process('## Alfred'), 'Alfred\n')
})

await t.test('should support heading (setext)', async function () {
assert.equal(await proc('Alfred\n====='), 'Alfred\n')
assert.equal(await process('Alfred\n====='), 'Alfred\n')
})

await t.test('should support a list item', async function () {
assert.equal(
await proc('- Hello\n * World\n + !'),
await process('- Hello\n * World\n + !'),
'Hello\n\nWorld\n\n!\n'
)
})

await t.test('should support a list', async function () {
assert.equal(
await proc('- Hello\n\n- World\n\n- !'),
await process('- Hello\n\n- World\n\n- !'),
'Hello\n\nWorld\n\n!\n'
)
})

await t.test('should support a list item (empty)', async function () {
assert.equal(await proc('- Hello\n- \n- World!'), 'Hello\n\nWorld!\n')
assert.equal(await process('- Hello\n- \n- World!'), 'Hello\n\nWorld!\n')
})

await t.test('should support a block quote', async function () {
assert.equal(await proc('> Hello\n> World\n> !'), 'Hello\nWorld\n!\n')
assert.equal(await process('> Hello\n> World\n> !'), 'Hello\nWorld\n!\n')
})

await t.test('should support an image', async function () {
assert.equal(await proc('![An image](image.png "test")'), 'An image\n')
assert.equal(await process('![An image](image.png "test")'), 'An image\n')
})

await t.test('should support an image (no alt)', async function () {
assert.equal(await proc('![](image.png "test")'), 'test\n')
assert.equal(await process('![](image.png "test")'), 'test\n')
})

await t.test('should support an image (no alt, no title)', async function () {
assert.equal(await proc('![](image.png)'), '')
assert.equal(await process('![](image.png)'), '')
})

await t.test(
'should support an image reference, definition',
async function () {
assert.equal(
await proc('![An image][id]\n\n[id]: http://example.com/a.jpg'),
await process('![An image][id]\n\n[id]: http://example.com/a.jpg'),
'An image\n'
)
}
)

await t.test('should support a thematic break', async function () {
assert.equal(await proc('---'), '')
assert.equal(await process('---'), '')
})

await t.test('should support a hard break', async function () {
assert.equal(await proc('A \nB'), 'A\nB\n')
assert.equal(await process('A \nB'), 'A\nB\n')
})

await t.test('should support a soft break', async function () {
assert.equal(await proc('A\nB'), 'A\nB\n')
assert.equal(await process('A\nB'), 'A\nB\n')
})

await t.test('should support a table', async function () {
assert.equal(await proc('| A | B |\n| - | - |\n| C | D |'), '')
assert.equal(await process('| A | B |\n| - | - |\n| C | D |'), '')
})

await t.test('should support code (indented)', async function () {
assert.equal(await proc('\talert("hello");'), '')
assert.equal(await process('\talert("hello");'), '')
})

await t.test('should support code (fenced)', async function () {
assert.equal(await proc('```js\nconsole.log("world");\n```'), '')
assert.equal(await process('```js\nconsole.log("world");\n```'), '')
})

await t.test('should support html (text)', async function () {
assert.equal(await proc('<sup>Hello</sup>'), 'Hello\n')
assert.equal(await process('<sup>Hello</sup>'), 'Hello\n')
})

await t.test('should support html (flow)', async function () {
assert.equal(await proc('<script>alert("world");</script>'), '')
assert.equal(await process('<script>alert("world");</script>'), '')
})

await t.test('should support html in an image', async function () {
assert.equal(
await proc(
await process(
'[<img src="http://example.com/a.jpg" />](http://example.com)'
),
''
)
})

await t.test('should support a footnote', async function () {
assert.equal(await proc('Hello[^1]\n\n[^1]: World'), 'Hello\n')
assert.equal(await process('Hello[^1]\n\n[^1]: World'), 'Hello\n')
})

await t.test('should support `options.keep` (empty)', async function () {
// "keep" option
assert.equal(
await proc('- **Hello**\n\n- World!', {keep: []}),
await process('- **Hello**\n\n- World!', {keep: []}),
'Hello\n\nWorld!\n'
)
})

await t.test('should support keeping lists', async function () {
assert.equal(
await proc('- **Hello**\n\n- World!', {keep: ['list', 'listItem']}),
await process('- **Hello**\n\n- World!', {keep: ['list', 'listItem']}),
'* Hello\n\n* World!\n'
)
})
Expand All @@ -219,7 +219,7 @@ test('stripMarkdown', async function (t) {
'should throw for unknown nodes in `keep` w/o handlers',
async function () {
try {
await proc('- **Hello**\n\n- World!', {
await process('- **Hello**\n\n- World!', {
keep: [
// @ts-expect-error: untyped node.
'typo'
Expand All @@ -238,14 +238,14 @@ test('stripMarkdown', async function (t) {
await t.test('should support `options.remove`', async function () {
// "remove" option
assert.equal(
await proc('I read this :cite[smith04]!', {remove: ['textDirective']}),
await process('I read this :cite[smith04]!', {remove: ['textDirective']}),
'I read this !\n'
)
})

await t.test('should support callbacks in `remove`', async function () {
assert.equal(
await proc(
await process(
'A :i[lovely] language known as :abbr[HTML]{title="HyperText Markup Language"}.',
{
remove: [
Expand Down Expand Up @@ -284,7 +284,7 @@ test('stripMarkdown', async function (t) {
* @returns {Promise<string>}
* Result.
*/
async function proc(value, options) {
async function process(value, options) {
return String(
await remark()
.use(remarkGfm)
Expand Down

0 comments on commit f2f0f62

Please sign in to comment.