@@ -21,8 +21,6 @@ import {handlers} from './handlers/index.js'
2121import { one } from './one.js'
2222import { all } from './all.js'
2323
24- export { one } from './one.js'
25-
2624/**
2725 * Transform hast to mdast.
2826 *
@@ -41,6 +39,7 @@ export function toMdast(tree, options) {
4139 const state = {
4240 patch,
4341 all : allBound ,
42+ one : oneBound ,
4443 options : options_ ,
4544 nodeById : byId ,
4645 handlers : options_ . handlers
@@ -69,7 +68,7 @@ export function toMdast(tree, options) {
6968 // @ts -expect-error: does return a transformer, that does accept any node.
7069 rehypeMinifyWhitespace ( { newlines : options_ . newlines === true } ) ( tree )
7170
72- const result = one ( state , tree , undefined )
71+ const result = state . one ( tree , undefined )
7372
7473 if ( ! result ) {
7574 mdast = { type : 'root' , children : [ ] }
@@ -168,3 +167,19 @@ function patch(origin, node) {
168167function allBound ( parent ) {
169168 return all ( this , parent )
170169}
170+
171+ /**
172+ * Transform a hast node to mdast.
173+ *
174+ * @this {State}
175+ * Info passed around about the current state.
176+ * @param {Node } node
177+ * Expected hast node.
178+ * @param {Parent | undefined } parent
179+ * Parent of `node`.
180+ * @returns {MdastNode | Array<MdastNode> | void }
181+ * mdast result.
182+ */
183+ function oneBound ( node , parent ) {
184+ return one ( this , node , parent )
185+ }
0 commit comments