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-label.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. 'use strict'
  2. var markdownLineEnding = require('../character/markdown-line-ending.js')
  3. var markdownSpace = require('../character/markdown-space.js')
  4. // eslint-disable-next-line max-params
  5. function labelFactory(effects, ok, nok, type, markerType, stringType) {
  6. var self = this
  7. var size = 0
  8. var data
  9. return start
  10. function start(code) {
  11. effects.enter(type)
  12. effects.enter(markerType)
  13. effects.consume(code)
  14. effects.exit(markerType)
  15. effects.enter(stringType)
  16. return atBreak
  17. }
  18. function atBreak(code) {
  19. if (
  20. code === null ||
  21. code === 91 ||
  22. (code === 93 && !data) ||
  23. /* c8 ignore next */
  24. (code === 94 &&
  25. /* c8 ignore next */
  26. !size &&
  27. /* c8 ignore next */
  28. '_hiddenFootnoteSupport' in self.parser.constructs) ||
  29. size > 999
  30. ) {
  31. return nok(code)
  32. }
  33. if (code === 93) {
  34. effects.exit(stringType)
  35. effects.enter(markerType)
  36. effects.consume(code)
  37. effects.exit(markerType)
  38. effects.exit(type)
  39. return ok
  40. }
  41. if (markdownLineEnding(code)) {
  42. effects.enter('lineEnding')
  43. effects.consume(code)
  44. effects.exit('lineEnding')
  45. return atBreak
  46. }
  47. effects.enter('chunkString', {
  48. contentType: 'string'
  49. })
  50. return label(code)
  51. }
  52. function label(code) {
  53. if (
  54. code === null ||
  55. code === 91 ||
  56. code === 93 ||
  57. markdownLineEnding(code) ||
  58. size++ > 999
  59. ) {
  60. effects.exit('chunkString')
  61. return atBreak(code)
  62. }
  63. effects.consume(code)
  64. data = data || !markdownSpace(code)
  65. return code === 92 ? labelEscape : label
  66. }
  67. function labelEscape(code) {
  68. if (code === 91 || code === 92 || code === 93) {
  69. effects.consume(code)
  70. size++
  71. return label
  72. }
  73. return label(code)
  74. }
  75. }
  76. module.exports = labelFactory