* Process the result from unified some more. * * @param {Nodes} tree * Tree. * @param {Readonly } options * Props. * @returns {ReactElement} * React element.
(tree, options)
| 311 | * React element. |
| 312 | */ |
| 313 | function post(tree, options) { |
| 314 | const allowedElements = options.allowedElements |
| 315 | const allowElement = options.allowElement |
| 316 | const components = options.components |
| 317 | const disallowedElements = options.disallowedElements |
| 318 | const skipHtml = options.skipHtml |
| 319 | const unwrapDisallowed = options.unwrapDisallowed |
| 320 | const urlTransform = options.urlTransform || defaultUrlTransform |
| 321 | |
| 322 | for (const deprecation of deprecations) { |
| 323 | if (Object.hasOwn(options, deprecation.from)) { |
| 324 | unreachable( |
| 325 | 'Unexpected `' + |
| 326 | deprecation.from + |
| 327 | '` prop, ' + |
| 328 | (deprecation.to |
| 329 | ? 'use `' + deprecation.to + '` instead' |
| 330 | : 'remove it') + |
| 331 | ' (see <' + |
| 332 | changelog + |
| 333 | '#' + |
| 334 | deprecation.id + |
| 335 | '> for more info)' |
| 336 | ) |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | if (allowedElements && disallowedElements) { |
| 341 | unreachable( |
| 342 | 'Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other' |
| 343 | ) |
| 344 | } |
| 345 | |
| 346 | visit(tree, transform) |
| 347 | |
| 348 | return toJsxRuntime(tree, { |
| 349 | Fragment, |
| 350 | components, |
| 351 | ignoreInvalidStyle: true, |
| 352 | jsx, |
| 353 | jsxs, |
| 354 | passKeys: true, |
| 355 | passNode: true |
| 356 | }) |
| 357 | |
| 358 | /** @type {BuildVisitor<Root>} */ |
| 359 | function transform(node, index, parent) { |
| 360 | if (node.type === 'raw' && parent && typeof index === 'number') { |
| 361 | if (skipHtml) { |
| 362 | parent.children.splice(index, 1) |
| 363 | } else { |
| 364 | parent.children[index] = {type: 'text', value: node.value} |
| 365 | } |
| 366 | |
| 367 | return index |
| 368 | } |
| 369 | |
| 370 | if (node.type === 'element') { |
no outgoing calls
no test coverage detected
searching dependent graphs…