thematic-break.js 571 B

123456789101112131415161718192021
  1. /**
  2. * @import {State} from 'mdast-util-to-markdown'
  3. * @import {Parents, ThematicBreak} from 'mdast'
  4. */
  5. import {checkRuleRepetition} from '../util/check-rule-repetition.js'
  6. import {checkRule} from '../util/check-rule.js'
  7. /**
  8. * @param {ThematicBreak} _
  9. * @param {Parents | undefined} _1
  10. * @param {State} state
  11. * @returns {string}
  12. */
  13. export function thematicBreak(_, _1, state) {
  14. const value = (
  15. checkRule(state) + (state.options.ruleSpaces ? ' ' : '')
  16. ).repeat(checkRuleRepetition(state))
  17. return state.options.ruleSpaces ? value.slice(0, -1) : value
  18. }