Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
* Update `unified` (10.0.0)
  See: <https://github.com/unifiedjs/unified/releases/tag/10.0.0>
* Update `vfile` (5.0.0)
  See: <https://github.com/vfile/vfile/releases/tag/5.0.0>
  Importantly this renames ~~`vfile.contents`~~ to `vfile.value`
* Update `hast-util-from-parse5` (7.0.0)
  See: <https://github.com/syntax-tree/hast-util-from-parse5/releases/tag/7.0.0>
  Importantly this removes support for non-HTML doctypes
  Use xast if you’re not using HTML
* Update `hast-util-to-html` (8.0.0)
  See: <https://github.com/syntax-tree/hast-util-to-html/releases/tag/8.0.0>
  Importantly this removes support for non-HTML doctypes
  Use xast if you’re not using HTML
  • Loading branch information
wooorm committed Jul 30, 2021
1 parent 4681a82 commit 2d9f521
Show file tree
Hide file tree
Showing 91 changed files with 151 additions and 166 deletions.
17 changes: 9 additions & 8 deletions package.json
Expand Up @@ -10,19 +10,20 @@
},
"type": "module",
"devDependencies": {
"bail": "^1.0.0",
"bail": "^2.0.0",
"c8": "^7.0.0",
"dtslint": "^4.0.0",
"hast-util-assert": "^2.0.0",
"lerna": "^3.0.0",
"mdast-zone": "^4.0.0",
"hast-util-assert": "^3.0.0",
"lerna": "^4.0.0",
"mdast-zone": "^5.0.0",
"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"tape": "^5.0.0",
"to-vfile": "^6.0.0",
"unist-builder": "^2.0.0",
"unist-util-remove-position": "^3.0.0",
"to-vfile": "^7.0.0",
"unified": "^10.0.0",
"unist-builder": "^3.0.0",
"unist-util-remove-position": "^4.0.0",
"xo": "^0.38.0"
},
"scripts": {
Expand Down Expand Up @@ -50,7 +51,7 @@
"remarkConfig": {
"plugins": [
"preset-wooorm",
"./script/parse-error"
"./script/parse-error.js"
]
}
}
2 changes: 1 addition & 1 deletion packages/rehype-parse/index.js
@@ -1,5 +1,5 @@
import fromParse5 from 'hast-util-from-parse5'
import Parser5 from 'parse5/lib/parser/index.js'
import {fromParse5} from 'hast-util-from-parse5'
import {errors} from './errors.js'

const base = 'https://html.spec.whatwg.org/multipage/parsing.html#parse-error-'
Expand Down
2 changes: 1 addition & 1 deletion packages/rehype-parse/package.json
Expand Up @@ -36,7 +36,7 @@
"index.js"
],
"dependencies": {
"hast-util-from-parse5": "^6.0.0",
"hast-util-from-parse5": "^7.0.0",
"parse5": "^6.0.0"
},
"xo": false
Expand Down
4 changes: 2 additions & 2 deletions packages/rehype-stringify/index.js
@@ -1,11 +1,11 @@
import toHTML from 'hast-util-to-html'
import {toHtml} from 'hast-util-to-html'

export default function rehypeStringify(config) {
const settings = Object.assign({}, config, this.data('settings'))

this.Compiler = compiler

function compiler(tree) {
return toHTML(tree, settings)
return toHtml(tree, settings)
}
}
2 changes: 1 addition & 1 deletion packages/rehype-stringify/package.json
Expand Up @@ -37,7 +37,7 @@
"index.js"
],
"dependencies": {
"hast-util-to-html": "^7.1.1"
"hast-util-to-html": "^8.0.0"
},
"xo": false
}
2 changes: 1 addition & 1 deletion packages/rehype/index.js
@@ -1,4 +1,4 @@
import unified from 'unified'
import {unified} from 'unified'
import rehypeParse from 'rehype-parse'
import rehypeStringify from 'rehype-stringify'

Expand Down
2 changes: 1 addition & 1 deletion packages/rehype/package.json
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"rehype-parse": "^7.0.0",
"rehype-stringify": "^8.0.0",
"unified": "^9.0.0"
"unified": "^10.0.0"
},
"homepage": "https://github.com/rehypejs/rehype",
"repository": "https://github.com/rehypejs/rehype/tree/main/packages/rehype",
Expand Down
6 changes: 3 additions & 3 deletions script/parse-error.js
@@ -1,8 +1,8 @@
import fs from 'fs'
import u from 'unist-builder'
import unified from 'unified'
import {u} from 'unist-builder'
import {unified} from 'unified'
import parse from 'remark-parse'
import zone from 'mdast-zone'
import {zone} from 'mdast-zone'
import {errors} from '../packages/rehype-parse/errors.js'

const pkg = JSON.parse(fs.readFileSync('package.json'))
Expand Down
6 changes: 3 additions & 3 deletions script/regenerate-fixtures.js
@@ -1,11 +1,11 @@
import fs from 'fs'
import path from 'path'
import bail from 'bail'
import rehype from '../packages/rehype/index.js'
import {bail} from 'bail'
import {rehype} from '../packages/rehype/index.js'

const join = path.join

const root = join(__dirname, '..', 'test', 'fixtures')
const root = join(process.cwd(), 'test', 'fixtures')

fs.readdir(join(root), (error, files) => {
let index = -1
Expand Down
52 changes: 30 additions & 22 deletions test/api.js
@@ -1,25 +1,28 @@
import fs from 'fs'
import path from 'path'
import test from 'tape'
import vfile from 'to-vfile'
import clean from 'unist-util-remove-position'
import hast from 'hast-util-assert'
import unified from '../packages/rehype/node_modules/unified/index.js'
import parse from '../packages/rehype-parse/index.js'
import stringify from '../packages/rehype-stringify/index.js'
import {readSync} from 'to-vfile'
import {removePosition} from 'unist-util-remove-position'
import {assert} from 'hast-util-assert'
import {unified} from '../packages/rehype/node_modules/unified/index.js'
import rehypeParse from '../packages/rehype-parse/index.js'
import rehypeStringify from '../packages/rehype-stringify/index.js'
import {rehype} from '../packages/rehype/index.js'

const fragment = {fragment: true}

test('rehype().parse(file)', (t) => {
t.equal(
unified().use(parse).parse('Alfred').children.length,
unified().use(rehypeParse).parse('Alfred').children.length,
1,
'should accept a `string`'
)

t.deepEqual(
clean(unified().use(parse, fragment).parse('<img><span></span>'), true),
removePosition(
unified().use(rehypeParse, fragment).parse('<img><span></span>'),
true
),
{
type: 'root',
children: [
Expand All @@ -42,7 +45,10 @@ test('rehype().parse(file)', (t) => {
)

t.deepEqual(
clean(unified().use(parse, fragment).parse('<foo><span></span>'), true),
removePosition(
unified().use(rehypeParse, fragment).parse('<foo><span></span>'),
true
),
{
type: 'root',
children: [
Expand Down Expand Up @@ -71,65 +77,67 @@ test('rehype().parse(file)', (t) => {
test('rehype().stringify(ast, file, options?)', (t) => {
t.throws(
() => {
unified().use(stringify).stringify(false)
unified().use(rehypeStringify).stringify(false)
},
/false/,
'should throw when `ast` is not a node'
)

t.throws(
() => {
unified().use(stringify).stringify({type: 'unicorn'})
unified().use(rehypeStringify).stringify({type: 'unicorn'})
},
/unicorn/,
'should throw when `ast` is not a valid node'
)

t.equal(
unified().use(stringify).stringify({type: 'text', value: 'alpha < bravo'}),
unified()
.use(rehypeStringify)
.stringify({type: 'text', value: 'alpha < bravo'}),
'alpha &#x3C; bravo',
'should escape entities'
)

t.equal(
unified()
.use(stringify, {entities: {}})
.use(rehypeStringify, {entities: {}})
.stringify({type: 'text', value: 'alpha < bravo'}),
'alpha &#x3C; bravo',
'should encode entities (numbered by default)'
)

t.equal(
unified()
.use(stringify, {entities: {useNamedReferences: true}})
.use(rehypeStringify, {entities: {useNamedReferences: true}})
.stringify({type: 'text', value: 'alpha < bravo'}),
'alpha &lt; bravo',
'should encode entities (numbered by default)'
)

t.equal(
unified().use(stringify).stringify({type: 'element', tagName: 'img'}),
unified().use(rehypeStringify).stringify({type: 'element', tagName: 'img'}),
'<img>',
'should not close void elements'
)

t.equal(
unified()
.use(stringify, {closeSelfClosing: true})
.use(rehypeStringify, {closeSelfClosing: true})
.stringify({type: 'element', tagName: 'img'}),
'<img />',
'should close void elements if `closeSelfClosing` is given'
)

t.equal(
unified().use(stringify).stringify({type: 'element', tagName: 'foo'}),
unified().use(rehypeStringify).stringify({type: 'element', tagName: 'foo'}),
'<foo></foo>',
'should not close unknown elements by default'
)

t.equal(
unified()
.use(stringify, {voids: 'foo'})
.use(rehypeStringify, {voids: 'foo'})
.stringify({type: 'element', tagName: 'foo'}),
'<foo>',
'should close void elements if configured'
Expand Down Expand Up @@ -225,7 +233,7 @@ test('fixtures', (t) => {
setImmediate(next) // Queue next.

t.test(fixture, (st) => {
const file = vfile.readSync(path.join(fp, 'index.html'))
const file = readSync(path.join(fp, 'index.html'))
let config = {}
let tree
let result
Expand All @@ -252,7 +260,7 @@ test('fixtures', (t) => {
return
}

hast(node)
assert(node)

st.deepEqual(tree, node, 'should parse `' + fixture + '`')

Expand All @@ -266,8 +274,8 @@ test('fixtures', (t) => {

if (config.reprocess !== false) {
st.deepEqual(
clean(node),
clean(rehype().data('settings', config).parse(out)),
removePosition(node),
removePosition(rehype().data('settings', config).parse(out)),
'should re-parse `' + fixture + '`'
)
}
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/doctype-almost-standards/config.json
@@ -0,0 +1,3 @@
{
"reprocess": false
}
3 changes: 0 additions & 3 deletions test/fixtures/doctype-almost-standards/index.json
Expand Up @@ -3,9 +3,6 @@
"children": [
{
"type": "doctype",
"name": "html",
"public": "-//W3C//DTD XHTML 1.0 Transitional//EN",
"system": null,
"position": {
"start": {
"line": 1,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/doctype-almost-standards/result.html
@@ -1 +1 @@
<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN"><html><head></head><body></body></html>
<!doctype html><html><head></head><body></body></html>
3 changes: 0 additions & 3 deletions test/fixtures/doctype-legacy-double/index.json
Expand Up @@ -3,9 +3,6 @@
"children": [
{
"type": "doctype",
"name": "html",
"public": null,
"system": "about:legacy-compat",
"position": {
"start": {
"line": 1,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/doctype-legacy-double/result.html
@@ -1 +1 @@
<!doctype html system "about:legacy-compat"><html><head></head><body></body></html>
<!doctype html><html><head></head><body></body></html>
3 changes: 0 additions & 3 deletions test/fixtures/doctype-legacy-single/index.json
Expand Up @@ -3,9 +3,6 @@
"children": [
{
"type": "doctype",
"name": "html",
"public": null,
"system": "about:legacy-compat",
"position": {
"start": {
"line": 1,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/doctype-legacy-single/result.html
@@ -1 +1 @@
<!doctype html system "about:legacy-compat"><html><head></head><body></body></html>
<!doctype html><html><head></head><body></body></html>
3 changes: 3 additions & 0 deletions test/fixtures/doctype-nameless/config.json
@@ -0,0 +1,3 @@
{
"reprocess": false
}
3 changes: 0 additions & 3 deletions test/fixtures/doctype-nameless/index.json
Expand Up @@ -3,9 +3,6 @@
"children": [
{
"type": "doctype",
"name": "",
"public": null,
"system": null,
"position": {
"start": {
"line": 1,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/doctype-nameless/result.html
@@ -1 +1 @@
<!doctype><html><head></head><body></body></html>
<!doctype html><html><head></head><body></body></html>
3 changes: 3 additions & 0 deletions test/fixtures/doctype-quirksmode-ibm/config.json
@@ -0,0 +1,3 @@
{
"reprocess": false
}
3 changes: 0 additions & 3 deletions test/fixtures/doctype-quirksmode-ibm/index.json
Expand Up @@ -3,9 +3,6 @@
"children": [
{
"type": "doctype",
"name": "html",
"public": null,
"system": "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",
"position": {
"start": {
"line": 1,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/doctype-quirksmode-ibm/result.html
@@ -1 +1 @@
<!doctype html system "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"><html><head></head><body></body></html>
<!doctype html><html><head></head><body></body></html>
3 changes: 0 additions & 3 deletions test/fixtures/doctype-quotes-double/index.json
Expand Up @@ -3,9 +3,6 @@
"children": [
{
"type": "doctype",
"name": "html",
"public": "-//Alpha \"bravo\" charlie//DTD HTML Extended 1.0//EN",
"system": null,
"position": {
"start": {
"line": 1,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/doctype-quotes-double/result.html
@@ -1 +1 @@
<!doctype html public '-//Alpha "bravo" charlie//DTD HTML Extended 1.0//EN'><html><head></head><body></body></html>
<!doctype html><html><head></head><body></body></html>
3 changes: 0 additions & 3 deletions test/fixtures/doctype-quotes-single/index.json
Expand Up @@ -3,9 +3,6 @@
"children": [
{
"type": "doctype",
"name": "html",
"public": "-//Alpha 'bravo' charlie//DTD HTML Extended 1.0//EN",
"system": null,
"position": {
"start": {
"line": 1,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/doctype-quotes-single/result.html
@@ -1 +1 @@
<!doctype html public "-//Alpha 'bravo' charlie//DTD HTML Extended 1.0//EN"><html><head></head><body></body></html>
<!doctype html><html><head></head><body></body></html>
3 changes: 0 additions & 3 deletions test/fixtures/doctype/index.json
Expand Up @@ -3,9 +3,6 @@
"children": [
{
"type": "doctype",
"name": "html",
"public": null,
"system": null,
"position": {
"start": {
"line": 1,
Expand Down

0 comments on commit 2d9f521

Please sign in to comment.