check-list-item-indent.js 512 B

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