Skip to content

Commit

Permalink
Use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 3, 2021
1 parent 7a3d622 commit 21813ba
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
8 changes: 2 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
'use strict'

var mdast2nlcst = require('mdast-util-to-nlcst')

module.exports = remark2retext
import mdast2nlcst from 'mdast-util-to-nlcst'

// Attacher.
// If a destination processor is given, runs the destination with the new nlcst
// tree (bridge mode).
// If a parser is given, returns the nlcst tree: further plugins run on that
// tree (mutate mode).
function remark2retext(destination, options) {
export default function remarkRetext(destination, options) {
var fn = destination && destination.run ? bridge : mutate
return fn(destination, options)
}
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"sideEffects": false,
"type": "module",
"main": "index.js",
"files": [
"index.js"
],
Expand Down Expand Up @@ -60,7 +63,10 @@
},
"xo": {
"prettier": true,
"esnext": false
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off"
}
},
"remarkConfig": {
"plugins": [
Expand Down
30 changes: 14 additions & 16 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
'use strict'
import test from 'tape'
import unified from 'unified'
import remarkParse from 'remark-parse'
import retextEnglish from 'retext-english'
import remarkStringify from 'remark-stringify'
import retextStringify from 'retext-stringify'
import remarkRetext from './index.js'

var test = require('tape')
var unified = require('unified')
var parse = require('remark-parse')
var english = require('retext-english')
var markdown = require('remark-stringify')
var naturalLanguage = require('retext-stringify')
var remark2retext = require('.')

test('remark2retext()', function (t) {
test('remarkRetext', function (t) {
t.equal(
unified()
.use(parse)
.use(remark2retext, english.Parser)
.use(naturalLanguage)
.use(remarkParse)
.use(remarkRetext, retextEnglish.Parser)
.use(retextStringify)
.processSync('## Hello, world! ##')
.toString(),
'Hello, world!',
Expand All @@ -22,9 +20,9 @@ test('remark2retext()', function (t) {

t.equal(
unified()
.use(parse)
.use(remark2retext, unified().use(english))
.use(markdown)
.use(remarkParse)
.use(remarkRetext, unified().use(retextEnglish))
.use(remarkStringify)
.processSync('## Hello, world! ##')
.toString(),
'## Hello, world!\n',
Expand Down

0 comments on commit 21813ba

Please sign in to comment.