Skip to content

Commit 19301e7

Browse files
committed
Add containerPhrasing, containerFlow helpers on state
1 parent a638e2a commit 19301e7

15 files changed

+132
-52
lines changed

lib/handle/blockquote.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* @typedef {import('../types.js').Map} Map
77
*/
88

9-
import {containerFlow} from '../util/container-flow.js'
109
import {track} from '../util/track.js'
1110

1211
/**
@@ -22,7 +21,7 @@ export function blockquote(node, _, state, info) {
2221
tracker.move('> ')
2322
tracker.shift(2)
2423
const value = state.indentLines(
25-
containerFlow(node, state, tracker.current()),
24+
state.containerFlow(node, tracker.current()),
2625
map
2726
)
2827
exit()

lib/handle/emphasis.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
import {checkEmphasis} from '../util/check-emphasis.js'
9-
import {containerPhrasing} from '../util/container-phrasing.js'
109
import {track} from '../util/track.js'
1110

1211
emphasis.peek = emphasisPeek
@@ -28,7 +27,7 @@ export function emphasis(node, _, state, info) {
2827
const tracker = track(info)
2928
let value = tracker.move(marker)
3029
value += tracker.move(
31-
containerPhrasing(node, state, {
30+
state.containerPhrasing(node, {
3231
before: value,
3332
after: marker,
3433
...tracker.current()

lib/handle/heading.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
import {formatHeadingAsSetext} from '../util/format-heading-as-setext.js'
9-
import {containerPhrasing} from '../util/container-phrasing.js'
109
import {track} from '../util/track.js'
1110

1211
/**
@@ -23,7 +22,7 @@ export function heading(node, _, state, info) {
2322
if (formatHeadingAsSetext(node, state)) {
2423
const exit = state.enter('headingSetext')
2524
const subexit = state.enter('phrasing')
26-
const value = containerPhrasing(node, state, {
25+
const value = state.containerPhrasing(node, {
2726
...tracker.current(),
2827
before: '\n',
2928
after: '\n'
@@ -54,7 +53,7 @@ export function heading(node, _, state, info) {
5453
// we’ve tracked one too many characters.
5554
tracker.move(sequence + ' ')
5655

57-
let value = containerPhrasing(node, state, {
56+
let value = state.containerPhrasing(node, {
5857
before: '# ',
5958
after: '\n',
6059
...tracker.current()

lib/handle/link-reference.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
import {association} from '../util/association.js'
9-
import {containerPhrasing} from '../util/container-phrasing.js'
109
import {safe} from '../util/safe.js'
1110
import {track} from '../util/track.js'
1211

@@ -25,7 +24,7 @@ export function linkReference(node, _, state, info) {
2524
let subexit = state.enter('label')
2625
const tracker = track(info)
2726
let value = tracker.move('[')
28-
const text = containerPhrasing(node, state, {
27+
const text = state.containerPhrasing(node, {
2928
before: value,
3029
after: ']',
3130
...tracker.current()

lib/handle/link.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import {checkQuote} from '../util/check-quote.js'
1010
import {formatLinkAsAutolink} from '../util/format-link-as-autolink.js'
11-
import {containerPhrasing} from '../util/container-phrasing.js'
1211
import {safe} from '../util/safe.js'
1312
import {track} from '../util/track.js'
1413

@@ -37,7 +36,7 @@ export function link(node, _, state, info) {
3736
exit = state.enter('autolink')
3837
let value = tracker.move('<')
3938
value += tracker.move(
40-
containerPhrasing(node, state, {
39+
state.containerPhrasing(node, {
4140
before: value,
4241
after: '>',
4342
...tracker.current()
@@ -53,7 +52,7 @@ export function link(node, _, state, info) {
5352
subexit = state.enter('label')
5453
let value = tracker.move('[')
5554
value += tracker.move(
56-
containerPhrasing(node, state, {
55+
state.containerPhrasing(node, {
5756
before: value,
5857
after: '](',
5958
...tracker.current()

lib/handle/list-item.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import {checkBullet} from '../util/check-bullet.js'
1010
import {checkListItemIndent} from '../util/check-list-item-indent.js'
11-
import {containerFlow} from '../util/container-flow.js'
1211
import {track} from '../util/track.js'
1312

1413
/**
@@ -49,7 +48,7 @@ export function listItem(node, parent, state, info) {
4948
tracker.shift(size)
5049
const exit = state.enter('listItem')
5150
const value = state.indentLines(
52-
containerFlow(node, state, tracker.current()),
51+
state.containerFlow(node, tracker.current()),
5352
map
5453
)
5554
exit()

lib/handle/list.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* @typedef {import('../types.js').Info} Info
66
*/
77

8-
import {containerFlow} from '../util/container-flow.js'
98
import {checkBullet} from '../util/check-bullet.js'
109
import {checkBulletOther} from '../util/check-bullet-other.js'
1110
import {checkBulletOrdered} from '../util/check-bullet-ordered.js'
@@ -106,7 +105,7 @@ export function list(node, parent, state, info) {
106105
}
107106

108107
state.bulletCurrent = bullet
109-
const value = containerFlow(node, state, info)
108+
const value = state.containerFlow(node, info)
110109
state.bulletLastUsed = bullet
111110
state.bulletCurrent = bulletCurrent
112111
exit()

lib/handle/paragraph.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* @typedef {import('../types.js').Info} Info
66
*/
77

8-
import {containerPhrasing} from '../util/container-phrasing.js'
9-
108
/**
119
* @param {Paragraph} node
1210
* @param {Parent | undefined} _
@@ -17,7 +15,7 @@ import {containerPhrasing} from '../util/container-phrasing.js'
1715
export function paragraph(node, _, state, info) {
1816
const exit = state.enter('paragraph')
1917
const subexit = state.enter('phrasing')
20-
const value = containerPhrasing(node, state, info)
18+
const value = state.containerPhrasing(node, info)
2119
subexit()
2220
exit()
2321
return value

lib/handle/root.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*/
77

88
import {phrasing} from 'mdast-util-phrasing'
9-
import {containerFlow} from '../util/container-flow.js'
10-
import {containerPhrasing} from '../util/container-phrasing.js'
119

1210
/**
1311
* @param {Root} node
@@ -19,7 +17,7 @@ import {containerPhrasing} from '../util/container-phrasing.js'
1917
export function root(node, _, state, info) {
2018
// Note: `html` nodes are ambiguous.
2119
const hasPhrasing = node.children.some((d) => phrasing(d))
22-
const fn = hasPhrasing ? containerPhrasing : containerFlow
20+
const fn = hasPhrasing ? state.containerPhrasing : state.containerFlow
2321
// @ts-expect-error: `root`s are supposed to have one type of content
24-
return fn(node, state, info)
22+
return fn.call(state, node, info)
2523
}

lib/handle/strong.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
import {checkStrong} from '../util/check-strong.js'
9-
import {containerPhrasing} from '../util/container-phrasing.js'
109
import {track} from '../util/track.js'
1110

1211
strong.peek = strongPeek
@@ -28,7 +27,7 @@ export function strong(node, _, state, info) {
2827
const tracker = track(info)
2928
let value = tracker.move(marker + marker)
3029
value += tracker.move(
31-
containerPhrasing(node, state, {
30+
state.containerPhrasing(node, {
3231
before: value,
3332
after: marker,
3433
...tracker.current()

0 commit comments

Comments
 (0)