line-ending.js 676 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * @import {
  3. * Construct,
  4. * State,
  5. * TokenizeContext,
  6. * Tokenizer
  7. * } from 'micromark-util-types'
  8. */
  9. import { factorySpace } from 'micromark-factory-space';
  10. import { markdownLineEnding } from 'micromark-util-character';
  11. /** @type {Construct} */
  12. export const lineEnding = {
  13. name: 'lineEnding',
  14. tokenize: tokenizeLineEnding
  15. };
  16. /**
  17. * @this {TokenizeContext}
  18. * Context.
  19. * @type {Tokenizer}
  20. */
  21. function tokenizeLineEnding(effects, ok) {
  22. return start;
  23. /** @type {State} */
  24. function start(code) {
  25. effects.enter("lineEnding");
  26. effects.consume(code);
  27. effects.exit("lineEnding");
  28. return factorySpace(effects, ok, "linePrefix");
  29. }
  30. }