Skip to content

Commit

Permalink
Remove footnotes from output and enable gfm tests
Browse files Browse the repository at this point in the history
Closes GH-25.

Reviewed-by: Christian Murphy <[email protected]>
Reviewed-by: Titus Wormer <[email protected]>
  • Loading branch information
stefanprobst authored Jul 20, 2021
1 parent 625506c commit b5eaf32
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ var defaults = {
tableCell: empty,
definition: empty,
yaml: empty,
toml: empty
toml: empty,

footnoteReference: empty,
footnoteDefinition: empty
}

var own = {}.hasOwnProperty
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"prettier": "^2.0.0",
"remark": "^13.0.0",
"remark-cli": "^9.0.0",
"remark-footnotes": "^3.0.0",
"remark-gfm": "^1.0.0",
"remark-preset-wooorm": "^8.0.0",
"tape": "^5.0.0",
"tinyify": "^3.0.0",
Expand Down
18 changes: 13 additions & 5 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@

var test = require('tape')
var remark = require('remark')
var gfm = require('remark-gfm')
var footnotes = require('remark-footnotes')
var u = require('unist-builder')
var strip = require('.')

function proc(value, options) {
return remark().use(strip, options).processSync(value).toString().trimEnd()
return remark()
.use(gfm)
.use(footnotes)
.use(strip, options)
.processSync(value)
.toString()
.trimEnd()
}

test('stripMarkdown()', function (t) {
Expand Down Expand Up @@ -39,8 +47,7 @@ test('stripMarkdown()', function (t) {
t.equal(proc('_Alfred_'), 'Alfred', 'emphasis (2)')
t.equal(proc('**Alfred**'), 'Alfred', 'importance (1)')
t.equal(proc('__Alfred__'), 'Alfred', 'importance (2)')
// To do: add `remark-gfm` when that’s done.
// t.equal(proc('~~Alfred~~'), 'Alfred', 'strikethrough')
t.equal(proc('~~Alfred~~'), 'Alfred', 'strikethrough')
t.equal(proc('`Alfred`'), 'Alfred', 'inline code')
t.equal(proc('[Hello](world)'), 'Hello', 'link')
t.equal(proc('[**H**ello](world)'), 'Hello', 'importance in link')
Expand Down Expand Up @@ -77,8 +84,7 @@ test('stripMarkdown()', function (t) {
t.equal(proc('---'), '', 'thematic break')
t.equal(proc('A \nB'), 'A\nB', 'hard line break')
t.equal(proc('A\nB'), 'A\nB', 'soft line break')
// To do: add `remark-gfm` when that’s done.
// t.equal(proc('| A | B |\n| - | - |\n| C | D |'), '', 'table')
t.equal(proc('| A | B |\n| - | - |\n| C | D |'), '', 'table')
t.equal(proc('\talert("hello");'), '', 'code (1)')
t.equal(proc('```js\nconsole.log("world");\n```'), '', 'code (2)')
t.equal(proc('<sup>Hello</sup>'), 'Hello', 'html (1)')
Expand All @@ -89,6 +95,8 @@ test('stripMarkdown()', function (t) {
'html (3)'
)

t.equal(proc('Hello[^1]\n\n[^1]: World'), 'Hello', 'footnote')

// "keep" option
t.equal(
proc('- **Hello**\n\n- World!', {keep: []}),
Expand Down
2 changes: 2 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ declare namespace strip {
| 'definition'
| 'yaml'
| 'toml'
| 'footnoteReference'
| 'footnoteDefinition'
>
}
}
Expand Down

0 comments on commit b5eaf32

Please sign in to comment.