line-ending.mjs 585 B

12345678910111213141516171819202122
  1. var lineEnding = {
  2. name: 'lineEnding',
  3. tokenize: tokenizeLineEnding
  4. }
  5. export default lineEnding
  6. import assert from 'assert'
  7. import markdownLineEnding from '../character/markdown-line-ending.mjs'
  8. import types from '../constant/types.mjs'
  9. import spaceFactory from './factory-space.mjs'
  10. function tokenizeLineEnding(effects, ok) {
  11. return start
  12. function start(code) {
  13. assert(markdownLineEnding(code), 'expected eol')
  14. effects.enter(types.lineEnding)
  15. effects.consume(code)
  16. effects.exit(types.lineEnding)
  17. return spaceFactory(effects, ok, types.linePrefix)
  18. }
  19. }