Skip to content

Commit bffab60

Browse files
committed
Update @types/hast, utilities
1 parent e9a70cf commit bffab60

File tree

17 files changed

+158
-122
lines changed

17 files changed

+158
-122
lines changed

lib/handlers/dl.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ export function dl(state, node) {
116116
* mdast nodes.
117117
*/
118118
function handle(state, children) {
119-
const nodes = state.all({type: 'element', tagName: 'x', children})
119+
const nodes = state.all({
120+
type: 'element',
121+
tagName: 'x',
122+
properties: {},
123+
children
124+
})
120125
const listItems = state.toSpecificContent(nodes, create)
121126

122127
if (listItems.length === 0) {

lib/handlers/table-cell.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export function tableCell(state, node) {
2424

2525
if (rowSpan || colSpan) {
2626
const data = result.data || (result.data = {})
27+
// @ts-expect-error: we remove it later.
2728
if (rowSpan) data.hastUtilToMdastTemporaryRowSpan = rowSpan
29+
// @ts-expect-error: we remove it later.
2830
if (colSpan) data.hastUtilToMdastTemporaryColSpan = colSpan
2931
}
3032
}

lib/handlers/table.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@ export function table(state, node) {
6969
if (cell.data) {
7070
const colSpan =
7171
Number.parseInt(
72+
// @ts-expect-error: we remove it later.
7273
String(cell.data.hastUtilToMdastTemporaryColSpan),
7374
10
7475
) || 1
7576
const rowSpan =
7677
Number.parseInt(
78+
// @ts-expect-error: we remove it later.
7779
String(cell.data.hastUtilToMdastTemporaryRowSpan),
7880
10
7981
) || 1

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function toMdast(tree, options) {
6565
// ignored.
6666
// So clean up.
6767
visit(mdast, function (node, index, parent) {
68-
if (node.type === 'text' && index !== null && parent) {
68+
if (node.type === 'text' && index !== undefined && parent) {
6969
const previous = parent.children[index - 1]
7070

7171
if (previous && previous.type === node.type) {

lib/util/wrap.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/**
2+
* @typedef {import('mdast-util-to-hast')} DoNotTouchItRegistersDataFields
3+
*
24
* @typedef {import('mdast').Root} Root
35
* @typedef {import('mdast').Content} Content
46
* @typedef {import('mdast').Delete} Delete
@@ -58,7 +60,10 @@ export function wrap(nodes) {
5860
* @returns {Array<Paragraph>}
5961
*/
6062
function onphrasing(nodes) {
61-
return nodes.every((d) => whitespace(d))
63+
return nodes.every((d) => {
64+
// @ts-expect-error: to do: remove when `hast-util-whitespace` is released.
65+
return whitespace(d)
66+
})
6267
? []
6368
: [{type: 'paragraph', children: nodes}]
6469
}

package.json

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,39 +37,40 @@
3737
],
3838
"dependencies": {
3939
"@types/extend": "^3.0.0",
40-
"@types/hast": "^2.0.0",
41-
"@types/mdast": "^3.0.0",
42-
"@types/unist": "^2.0.0",
40+
"@types/hast": "^3.0.0",
41+
"@types/mdast": "^4.0.0",
42+
"@types/unist": "^3.0.0",
4343
"extend": "^3.0.0",
44-
"hast-util-phrasing": "^2.0.0",
45-
"hast-util-to-html": "^8.0.4",
46-
"hast-util-to-text": "^3.0.0",
47-
"hast-util-whitespace": "^2.0.0",
48-
"mdast-util-phrasing": "^3.0.0",
49-
"mdast-util-to-string": "^3.0.0",
44+
"hast-util-phrasing": "^3.0.0",
45+
"hast-util-to-html": "^9.0.0",
46+
"hast-util-to-text": "^4.0.0",
47+
"hast-util-whitespace": "^3.0.0",
48+
"mdast-util-phrasing": "^4.0.0",
49+
"mdast-util-to-hast": "^13.0.0",
50+
"mdast-util-to-string": "^4.0.0",
5051
"rehype-minify-whitespace": "^5.0.0",
5152
"trim-trailing-lines": "^2.0.0",
52-
"unist-util-position": "^4.0.0",
53-
"unist-util-visit": "^4.0.0"
53+
"unist-util-position": "^5.0.0",
54+
"unist-util-visit": "^5.0.0"
5455
},
5556
"devDependencies": {
5657
"@types/node": "^20.0.0",
5758
"c8": "^8.0.0",
58-
"hast-util-from-html": "^1.0.0",
59-
"hastscript": "^7.0.0",
59+
"hast-util-from-html": "^2.0.0",
60+
"hastscript": "^8.0.0",
6061
"is-hidden": "^2.0.0",
61-
"mdast-util-assert": "^4.0.0",
62-
"mdast-util-from-markdown": "^1.0.0",
63-
"mdast-util-gfm": "^2.0.0",
64-
"mdast-util-to-markdown": "^1.0.0",
65-
"micromark-extension-gfm": "^2.0.0",
62+
"mdast-util-assert": "^5.0.0",
63+
"mdast-util-from-markdown": "^2.0.0",
64+
"mdast-util-gfm": "^3.0.0",
65+
"mdast-util-to-markdown": "^2.0.0",
66+
"micromark-extension-gfm": "^3.0.0",
6667
"prettier": "^3.0.0",
6768
"remark-cli": "^11.0.0",
6869
"remark-preset-wooorm": "^9.0.0",
6970
"type-coverage": "^2.0.0",
7071
"typescript": "^5.0.0",
71-
"unist-builder": "^3.0.0",
72-
"unist-util-remove-position": "^4.0.0",
72+
"unist-builder": "^4.0.0",
73+
"unist-util-remove-position": "^5.0.0",
7374
"xo": "^0.55.0"
7475
},
7576
"scripts": {

test/fixtures/data/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
New Products
22

3-
* Mini Ketchup
4-
* Jumbo Ketchup
5-
* Mega Jumbo Ketchup
3+
* Mini Ketchup
4+
* Jumbo Ketchup
5+
* Mega Jumbo Ketchup

test/fixtures/dir/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
* html
2-
* xhtml
3-
* css
1+
* html
2+
* xhtml
3+
* css

test/fixtures/dl/index.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
1-
* Firefox
1+
* Firefox
22

3-
A web browser.
3+
A web browser.
44

55
Alpha.
66

7-
* * Firefox
8-
* Mozilla Firefox
9-
* Fx
7+
* * Firefox
8+
* Mozilla Firefox
9+
* Fx
1010

11-
A web browser.
11+
A web browser.
1212

1313
Bravo.
1414

15-
* Firefox
15+
* Firefox
1616

17-
* A web browser.
18-
* A Red Panda.
17+
* A web browser.
18+
* A Red Panda.
1919

2020
Charlie.
2121

22-
* Firefox
22+
* Firefox
2323

24-
* A web browser.
24+
* A web browser.
2525

26-
* A Red Panda.
26+
* A Red Panda.
2727

28-
* ```js
29-
charlie();
30-
```
28+
* ```js
29+
charlie();
30+
```
3131

3232
Delta.
3333

34-
* Firefox
34+
* Firefox
3535

36-
* A web browser.
37-
* A Red Panda.
36+
* A web browser.
37+
* A Red Panda.
3838

39-
* Chrome
39+
* Chrome
4040

41-
* A web browser.
42-
* A chemical element.
41+
* A web browser.
42+
* A chemical element.
4343

4444
Echo.
4545

4646
Foxtrot.
4747

48-
* Chrome
48+
* Chrome
4949

50-
A web browser.
50+
A web browser.
5151

5252
Golf.
5353

54-
* Chrome
54+
* Chrome
5555

56-
A web browser.
56+
A web browser.
5757

5858
Hotel.
5959

60-
* Firefox
60+
* Firefox
6161

6262
India.
6363

64-
* Firefox.
64+
* Firefox.
6565

6666
Juliett.
6767

68-
* A web browser.
68+
* A web browser.

test/fixtures/gh-27/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
1. `something` Hello World? And now `channel`.
1+
1. `something` Hello World? And now `channel`.
22

33
A `for` loop… ye?

test/fixtures/implicit-paragraphs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ An **implicit** paragraph.
22

33
# An *explicit* paragraph
44

5-
1. *Emphasis* and **importance**.
5+
1. *Emphasis* and **importance**.
66

77
> # Heading
88
>

test/fixtures/nav/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
* [Home](#)
2-
* [About](#)
3-
* [Contact](#)
1+
* [Home](#)
2+
* [About](#)
3+
* [Contact](#)

test/fixtures/ol/index.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1-
2. Alpha
1+
2. Alpha
22

3-
3. Bravo
3+
3. Bravo
44

5-
4. ```js
6-
charlie();
7-
```
5+
4. ```js
6+
charlie();
7+
```
88

99
Foo.
1010

11-
1. Alpha
12-
2. Bravo
13-
3. Charlie
11+
1. Alpha
12+
2. Bravo
13+
3. Charlie
1414

1515
Bar.
1616

17-
3. Alpha
17+
3. Alpha
1818

19-
Bravo
19+
Bravo
2020

21-
4. Charlie
21+
4. Charlie
2222

23-
Delta
23+
Delta
2424

25-
5. Echo
25+
5. Echo
2626

27-
Foxtrot
27+
Foxtrot
2828

2929
Baz.
3030

3131
1.
3232

33-
2. Something else
33+
2. Something else
3434

3535
Qux.
3636

37-
1. Something else
37+
1. Something else
3838

3939
2.
4040

4141
Quux.
4242

43-
1. Something else
43+
1. Something else
4444

4545
2.
4646

4747
Quuux.
4848

49-
1. [x] Bravo
49+
1. [x] Bravo
5050

51-
2. [ ] Charlie
51+
2. [ ] Charlie
5252

53-
3. [x] Delta
53+
3. [x] Delta
5454

55-
4. [ ] Echo
55+
4. [ ] Echo
5656

57-
5. [ ] **Foxtrot**
57+
5. [ ] **Foxtrot**
5858

59-
6. [ ] **Golf**
59+
6. [ ] **Golf**

test/fixtures/straddling/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ Welcome! [This is home of...](about.html)
3838

3939
You can play with my cat simulator. To see the cat simulator, use one of the following links:
4040

41-
* [Download simulator file](cats.sim)
42-
* [Use online simulator](https://sims.example.com/watch?v=LYds5xY4INU)
41+
* [Download simulator file](cats.sim)
42+
* [Use online simulator](https://sims.example.com/watch?v=LYds5xY4INU)
4343

4444
Alternatively, upgrade to the Mellblom Browser. I’m quite proud of it.
4545

@@ -49,8 +49,8 @@ You can play with my cat simulator.
4949

5050
To see the cat simulator, use one of the following links:
5151

52-
* [Download simulator file](cats.sim)
53-
* [Use online simulator](https://sims.example.com/watch?v=LYds5xY4INU)
52+
* [Download simulator file](cats.sim)
53+
* [Use online simulator](https://sims.example.com/watch?v=LYds5xY4INU)
5454

5555
Alternatively, upgrade to the Mellblom Browser.
5656

test/fixtures/ul-ul/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Filed on [remark’s repo](https://github.com/remarkjs/remark/issues/269).
22

3-
* * Alpha
3+
* * Alpha

0 commit comments

Comments
 (0)