index.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * @typedef {import('mdast').Html} Html
  3. * @typedef {import('mdast').PhrasingContent} PhrasingContent
  4. */
  5. import {convert} from 'unist-util-is'
  6. /**
  7. * Check if the given value is *phrasing content*.
  8. *
  9. * > 👉 **Note**: Excludes `html`, which can be both phrasing or flow.
  10. *
  11. * @param node
  12. * Thing to check, typically `Node`.
  13. * @returns
  14. * Whether `value` is phrasing content.
  15. */
  16. export const phrasing =
  17. /** @type {(node?: unknown) => node is Exclude<PhrasingContent, Html>} */
  18. (
  19. convert([
  20. 'break',
  21. 'delete',
  22. 'emphasis',
  23. // To do: next major: removed since footnotes were added to GFM.
  24. 'footnote',
  25. 'footnoteReference',
  26. 'image',
  27. 'imageReference',
  28. 'inlineCode',
  29. // Enabled by `mdast-util-math`:
  30. 'inlineMath',
  31. 'link',
  32. 'linkReference',
  33. // Enabled by `mdast-util-mdx`:
  34. 'mdxJsxTextElement',
  35. // Enabled by `mdast-util-mdx`:
  36. 'mdxTextExpression',
  37. 'strong',
  38. 'text',
  39. // Enabled by `mdast-util-directive`:
  40. 'textDirective'
  41. ])
  42. )