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.

content.mjs 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. export var tokenize = initializeContent
  2. import assert from 'assert'
  3. import codes from '../character/codes.mjs'
  4. import markdownLineEnding from '../character/markdown-line-ending.mjs'
  5. import constants from '../constant/constants.mjs'
  6. import types from '../constant/types.mjs'
  7. import spaceFactory from '../tokenize/factory-space.mjs'
  8. function initializeContent(effects) {
  9. var contentStart = effects.attempt(
  10. this.parser.constructs.contentInitial,
  11. afterContentStartConstruct,
  12. paragraphInitial
  13. )
  14. var previous
  15. return contentStart
  16. function afterContentStartConstruct(code) {
  17. assert(
  18. code === codes.eof || markdownLineEnding(code),
  19. 'expected eol or eof'
  20. )
  21. if (code === codes.eof) {
  22. effects.consume(code)
  23. return
  24. }
  25. effects.enter(types.lineEnding)
  26. effects.consume(code)
  27. effects.exit(types.lineEnding)
  28. return spaceFactory(effects, contentStart, types.linePrefix)
  29. }
  30. function paragraphInitial(code) {
  31. assert(
  32. code !== codes.eof && !markdownLineEnding(code),
  33. 'expected anything other than a line ending or EOF'
  34. )
  35. effects.enter(types.paragraph)
  36. return lineStart(code)
  37. }
  38. function lineStart(code) {
  39. var token = effects.enter(types.chunkText, {
  40. contentType: constants.contentTypeText,
  41. previous: previous
  42. })
  43. if (previous) {
  44. previous.next = token
  45. }
  46. previous = token
  47. return data(code)
  48. }
  49. function data(code) {
  50. if (code === codes.eof) {
  51. effects.exit(types.chunkText)
  52. effects.exit(types.paragraph)
  53. effects.consume(code)
  54. return
  55. }
  56. if (markdownLineEnding(code)) {
  57. effects.consume(code)
  58. effects.exit(types.chunkText)
  59. return lineStart
  60. }
  61. // Data.
  62. effects.consume(code)
  63. return data
  64. }
  65. }