check-bullet.js 468 B

123456789101112131415161718192021
  1. /**
  2. * @import {Options, State} from 'mdast-util-to-markdown'
  3. */
  4. /**
  5. * @param {State} state
  6. * @returns {Exclude<Options['bullet'], null | undefined>}
  7. */
  8. export function checkBullet(state) {
  9. const marker = state.options.bullet || '*'
  10. if (marker !== '*' && marker !== '+' && marker !== '-') {
  11. throw new Error(
  12. 'Cannot serialize items with `' +
  13. marker +
  14. '` for `options.bullet`, expected `*`, `+`, or `-`'
  15. )
  16. }
  17. return marker
  18. }