site/node_modules/mdast-util-to-markdown/lib/handle/root.js

25 lines
645 B
JavaScript
Raw Normal View History

2024-10-14 06:09:33 +00:00
/**
* @typedef {import('mdast').Parents} Parents
* @typedef {import('mdast').Root} Root
* @typedef {import('../types.js').Info} Info
* @typedef {import('../types.js').State} State
*/
import {phrasing} from 'mdast-util-phrasing'
/**
* @param {Root} node
* @param {Parents | undefined} _
* @param {State} state
* @param {Info} info
* @returns {string}
*/
export function root(node, _, state, info) {
// Note: `html` nodes are ambiguous.
const hasPhrasing = node.children.some(function (d) {
return phrasing(d)
})
const fn = hasPhrasing ? state.containerPhrasing : state.containerFlow
return fn.call(state, node, info)
}