check-rule-repetition.js 480 B

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