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 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // No name because it must not be turned off.
  2. var content = {
  3. tokenize: tokenizeContent,
  4. resolve: resolveContent,
  5. interruptible: true,
  6. lazy: true
  7. }
  8. export default content
  9. import assert from 'assert'
  10. import codes from '../character/codes.mjs'
  11. import markdownLineEnding from '../character/markdown-line-ending.mjs'
  12. import constants from '../constant/constants.mjs'
  13. import types from '../constant/types.mjs'
  14. import prefixSize from '../util/prefix-size.mjs'
  15. import subtokenize from '../util/subtokenize.mjs'
  16. import spaceFactory from './factory-space.mjs'
  17. var continuationConstruct = {tokenize: tokenizeContinuation, partial: true}
  18. // Content is transparent: it’s parsed right now. That way, definitions are also
  19. // parsed right now: before text in paragraphs (specifically, media) are parsed.
  20. function resolveContent(events) {
  21. subtokenize(events)
  22. return events
  23. }
  24. function tokenizeContent(effects, ok) {
  25. var previous
  26. return start
  27. function start(code) {
  28. assert(
  29. code !== codes.eof && !markdownLineEnding(code),
  30. 'expected no eof or eol'
  31. )
  32. effects.enter(types.content)
  33. previous = effects.enter(types.chunkContent, {
  34. contentType: constants.contentTypeContent
  35. })
  36. return data(code)
  37. }
  38. function data(code) {
  39. if (code === codes.eof) {
  40. return contentEnd(code)
  41. }
  42. if (markdownLineEnding(code)) {
  43. return effects.check(
  44. continuationConstruct,
  45. contentContinue,
  46. contentEnd
  47. )(code)
  48. }
  49. // Data.
  50. effects.consume(code)
  51. return data
  52. }
  53. function contentEnd(code) {
  54. effects.exit(types.chunkContent)
  55. effects.exit(types.content)
  56. return ok(code)
  57. }
  58. function contentContinue(code) {
  59. assert(markdownLineEnding(code), 'expected eol')
  60. effects.consume(code)
  61. effects.exit(types.chunkContent)
  62. previous = previous.next = effects.enter(types.chunkContent, {
  63. contentType: constants.contentTypeContent,
  64. previous: previous
  65. })
  66. return data
  67. }
  68. }
  69. function tokenizeContinuation(effects, ok, nok) {
  70. var self = this
  71. return startLookahead
  72. function startLookahead(code) {
  73. assert(markdownLineEnding(code), 'expected a line ending')
  74. effects.enter(types.lineEnding)
  75. effects.consume(code)
  76. effects.exit(types.lineEnding)
  77. return spaceFactory(effects, prefixed, types.linePrefix)
  78. }
  79. function prefixed(code) {
  80. if (code === codes.eof || markdownLineEnding(code)) {
  81. return nok(code)
  82. }
  83. if (
  84. self.parser.constructs.disable.null.indexOf('codeIndented') > -1 ||
  85. prefixSize(self.events, types.linePrefix) < constants.tabSize
  86. ) {
  87. return effects.interrupt(self.parser.constructs.flow, nok, ok)(code)
  88. }
  89. return ok(code)
  90. }
  91. }