Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

thematic-break.mjs 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. var thematicBreak = {
  2. name: 'thematicBreak',
  3. tokenize: tokenizeThematicBreak
  4. }
  5. export default thematicBreak
  6. import assert from 'assert'
  7. import codes from '../character/codes.mjs'
  8. import markdownLineEnding from '../character/markdown-line-ending.mjs'
  9. import markdownSpace from '../character/markdown-space.mjs'
  10. import constants from '../constant/constants.mjs'
  11. import types from '../constant/types.mjs'
  12. import spaceFactory from './factory-space.mjs'
  13. function tokenizeThematicBreak(effects, ok, nok) {
  14. var size = 0
  15. var marker
  16. return start
  17. function start(code) {
  18. assert(
  19. code === codes.asterisk ||
  20. code === codes.dash ||
  21. code === codes.underscore,
  22. 'expected `*`, `-`, or `_`'
  23. )
  24. effects.enter(types.thematicBreak)
  25. marker = code
  26. return atBreak(code)
  27. }
  28. function atBreak(code) {
  29. if (code === marker) {
  30. effects.enter(types.thematicBreakSequence)
  31. return sequence(code)
  32. }
  33. if (markdownSpace(code)) {
  34. return spaceFactory(effects, atBreak, types.whitespace)(code)
  35. }
  36. if (
  37. size < constants.thematicBreakMarkerCountMin ||
  38. (code !== codes.eof && !markdownLineEnding(code))
  39. ) {
  40. return nok(code)
  41. }
  42. effects.exit(types.thematicBreak)
  43. return ok(code)
  44. }
  45. function sequence(code) {
  46. if (code === marker) {
  47. effects.consume(code)
  48. size++
  49. return sequence
  50. }
  51. effects.exit(types.thematicBreakSequence)
  52. return atBreak(code)
  53. }
  54. }