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.

code-indented.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. 'use strict'
  2. var markdownLineEnding = require('../character/markdown-line-ending.js')
  3. var chunkedSplice = require('../util/chunked-splice.js')
  4. var prefixSize = require('../util/prefix-size.js')
  5. var factorySpace = require('./factory-space.js')
  6. var codeIndented = {
  7. name: 'codeIndented',
  8. tokenize: tokenizeCodeIndented,
  9. resolve: resolveCodeIndented
  10. }
  11. var indentedContentConstruct = {
  12. tokenize: tokenizeIndentedContent,
  13. partial: true
  14. }
  15. function resolveCodeIndented(events, context) {
  16. var code = {
  17. type: 'codeIndented',
  18. start: events[0][1].start,
  19. end: events[events.length - 1][1].end
  20. }
  21. chunkedSplice(events, 0, 0, [['enter', code, context]])
  22. chunkedSplice(events, events.length, 0, [['exit', code, context]])
  23. return events
  24. }
  25. function tokenizeCodeIndented(effects, ok, nok) {
  26. return effects.attempt(indentedContentConstruct, afterPrefix, nok)
  27. function afterPrefix(code) {
  28. if (code === null) {
  29. return ok(code)
  30. }
  31. if (markdownLineEnding(code)) {
  32. return effects.attempt(indentedContentConstruct, afterPrefix, ok)(code)
  33. }
  34. effects.enter('codeFlowValue')
  35. return content(code)
  36. }
  37. function content(code) {
  38. if (code === null || markdownLineEnding(code)) {
  39. effects.exit('codeFlowValue')
  40. return afterPrefix(code)
  41. }
  42. effects.consume(code)
  43. return content
  44. }
  45. }
  46. function tokenizeIndentedContent(effects, ok, nok) {
  47. var self = this
  48. return factorySpace(effects, afterPrefix, 'linePrefix', 4 + 1)
  49. function afterPrefix(code) {
  50. if (markdownLineEnding(code)) {
  51. effects.enter('lineEnding')
  52. effects.consume(code)
  53. effects.exit('lineEnding')
  54. return factorySpace(effects, afterPrefix, 'linePrefix', 4 + 1)
  55. }
  56. return prefixSize(self.events, 'linePrefix') < 4 ? nok(code) : ok(code)
  57. }
  58. }
  59. module.exports = codeIndented