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.

character-reference.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. 'use strict'
  2. var decodeEntity = require('parse-entities/decode-entity.js')
  3. var asciiAlphanumeric = require('../character/ascii-alphanumeric.js')
  4. var asciiDigit = require('../character/ascii-digit.js')
  5. var asciiHexDigit = require('../character/ascii-hex-digit.js')
  6. function _interopDefaultLegacy(e) {
  7. return e && typeof e === 'object' && 'default' in e ? e : {default: e}
  8. }
  9. var decodeEntity__default = /*#__PURE__*/ _interopDefaultLegacy(decodeEntity)
  10. var characterReference = {
  11. name: 'characterReference',
  12. tokenize: tokenizeCharacterReference
  13. }
  14. function tokenizeCharacterReference(effects, ok, nok) {
  15. var self = this
  16. var size = 0
  17. var max
  18. var test
  19. return start
  20. function start(code) {
  21. effects.enter('characterReference')
  22. effects.enter('characterReferenceMarker')
  23. effects.consume(code)
  24. effects.exit('characterReferenceMarker')
  25. return open
  26. }
  27. function open(code) {
  28. if (code === 35) {
  29. effects.enter('characterReferenceMarkerNumeric')
  30. effects.consume(code)
  31. effects.exit('characterReferenceMarkerNumeric')
  32. return numeric
  33. }
  34. effects.enter('characterReferenceValue')
  35. max = 31
  36. test = asciiAlphanumeric
  37. return value(code)
  38. }
  39. function numeric(code) {
  40. if (code === 88 || code === 120) {
  41. effects.enter('characterReferenceMarkerHexadecimal')
  42. effects.consume(code)
  43. effects.exit('characterReferenceMarkerHexadecimal')
  44. effects.enter('characterReferenceValue')
  45. max = 6
  46. test = asciiHexDigit
  47. return value
  48. }
  49. effects.enter('characterReferenceValue')
  50. max = 7
  51. test = asciiDigit
  52. return value(code)
  53. }
  54. function value(code) {
  55. var token
  56. if (code === 59 && size) {
  57. token = effects.exit('characterReferenceValue')
  58. if (
  59. test === asciiAlphanumeric &&
  60. !decodeEntity__default['default'](self.sliceSerialize(token))
  61. ) {
  62. return nok(code)
  63. }
  64. effects.enter('characterReferenceMarker')
  65. effects.consume(code)
  66. effects.exit('characterReferenceMarker')
  67. effects.exit('characterReference')
  68. return ok
  69. }
  70. if (test(code) && size++ < max) {
  71. effects.consume(code)
  72. return value
  73. }
  74. return nok(code)
  75. }
  76. }
  77. module.exports = characterReference