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.

factory-title.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. 'use strict'
  2. var assert = require('assert')
  3. var codes = require('../character/codes.js')
  4. var markdownLineEnding = require('../character/markdown-line-ending.js')
  5. var constants = require('../constant/constants.js')
  6. var types = require('../constant/types.js')
  7. var factorySpace = require('./factory-space.js')
  8. function _interopDefaultLegacy(e) {
  9. return e && typeof e === 'object' && 'default' in e ? e : {default: e}
  10. }
  11. var assert__default = /*#__PURE__*/ _interopDefaultLegacy(assert)
  12. // eslint-disable-next-line max-params
  13. function titleFactory(effects, ok, nok, type, markerType, stringType) {
  14. var marker
  15. return start
  16. function start(code) {
  17. assert__default['default'](
  18. code === codes.quotationMark ||
  19. code === codes.apostrophe ||
  20. code === codes.leftParenthesis,
  21. 'expected `"`, `\'`, or `(`'
  22. )
  23. effects.enter(type)
  24. effects.enter(markerType)
  25. effects.consume(code)
  26. effects.exit(markerType)
  27. marker = code === codes.leftParenthesis ? codes.rightParenthesis : code
  28. return atFirstTitleBreak
  29. }
  30. function atFirstTitleBreak(code) {
  31. if (code === marker) {
  32. effects.enter(markerType)
  33. effects.consume(code)
  34. effects.exit(markerType)
  35. effects.exit(type)
  36. return ok
  37. }
  38. effects.enter(stringType)
  39. return atTitleBreak(code)
  40. }
  41. function atTitleBreak(code) {
  42. if (code === marker) {
  43. effects.exit(stringType)
  44. return atFirstTitleBreak(marker)
  45. }
  46. if (code === codes.eof) {
  47. return nok(code)
  48. }
  49. // Note: blank lines can’t exist in content.
  50. if (markdownLineEnding(code)) {
  51. effects.enter(types.lineEnding)
  52. effects.consume(code)
  53. effects.exit(types.lineEnding)
  54. return factorySpace(effects, atTitleBreak, types.linePrefix)
  55. }
  56. effects.enter(types.chunkString, {contentType: constants.contentTypeString})
  57. return title(code)
  58. }
  59. function title(code) {
  60. if (code === marker || code === codes.eof || markdownLineEnding(code)) {
  61. effects.exit(types.chunkString)
  62. return atTitleBreak(code)
  63. }
  64. effects.consume(code)
  65. return code === codes.backslash ? titleEscape : title
  66. }
  67. function titleEscape(code) {
  68. if (code === marker || code === codes.backslash) {
  69. effects.consume(code)
  70. return title
  71. }
  72. return title(code)
  73. }
  74. }
  75. module.exports = titleFactory