label-start-link.mjs 908 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import labelEnd from './label-end.mjs'
  2. var labelStartLink = {
  3. name: 'labelStartLink',
  4. tokenize: tokenizeLabelStartLink,
  5. resolveAll: labelEnd.resolveAll
  6. }
  7. export default labelStartLink
  8. import assert from 'assert'
  9. import codes from '../character/codes.mjs'
  10. import types from '../constant/types.mjs'
  11. function tokenizeLabelStartLink(effects, ok, nok) {
  12. var self = this
  13. return start
  14. function start(code) {
  15. assert(code === codes.leftSquareBracket, 'expected `[`')
  16. effects.enter(types.labelLink)
  17. effects.enter(types.labelMarker)
  18. effects.consume(code)
  19. effects.exit(types.labelMarker)
  20. effects.exit(types.labelLink)
  21. return after
  22. }
  23. function after(code) {
  24. /* c8 ignore next */
  25. return code === codes.caret &&
  26. /* c8 ignore next */
  27. '_hiddenFootnoteSupport' in self.parser.constructs
  28. ? /* c8 ignore next */
  29. nok(code)
  30. : ok(code)
  31. }
  32. }