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.js 2.2KB

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