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.

readme.md 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. # parse-entities
  2. [![Build][build-badge]][build]
  3. [![Coverage][coverage-badge]][coverage]
  4. [![Downloads][downloads-badge]][downloads]
  5. [![Size][size-badge]][size]
  6. Parse HTML character references: fast, spec-compliant, positional
  7. information.
  8. ## Install
  9. [npm][]:
  10. ```sh
  11. npm install parse-entities
  12. ```
  13. ## Use
  14. ```js
  15. var decode = require('parse-entities')
  16. decode('alpha &amp bravo')
  17. // => alpha & bravo
  18. decode('charlie &copycat; delta')
  19. // => charlie ©cat; delta
  20. decode('echo © foxtrot ≠ golf 𝌆 hotel')
  21. // => echo © foxtrot ≠ golf 𝌆 hotel
  22. ```
  23. ## API
  24. ## `parseEntities(value[, options])`
  25. ##### `options`
  26. ###### `options.additional`
  27. Additional character to accept (`string?`, default: `''`).
  28. This allows other characters, without error, when following an ampersand.
  29. ###### `options.attribute`
  30. Whether to parse `value` as an attribute value (`boolean?`, default:
  31. `false`).
  32. ###### `options.nonTerminated`
  33. Whether to allow non-terminated entities (`boolean`, default: `true`).
  34. For example, `&copycat` for `©cat`. This behaviour is spec-compliant but
  35. can lead to unexpected results.
  36. ###### `options.warning`
  37. Error handler ([`Function?`][warning]).
  38. ###### `options.text`
  39. Text handler ([`Function?`][text]).
  40. ###### `options.reference`
  41. Reference handler ([`Function?`][reference]).
  42. ###### `options.warningContext`
  43. Context used when invoking `warning` (`'*'`, optional).
  44. ###### `options.textContext`
  45. Context used when invoking `text` (`'*'`, optional).
  46. ###### `options.referenceContext`
  47. Context used when invoking `reference` (`'*'`, optional)
  48. ###### `options.position`
  49. Starting `position` of `value` (`Location` or `Position`, optional). Useful
  50. when dealing with values nested in some sort of syntax tree. The default is:
  51. ```js
  52. {
  53. start: {line: 1, column: 1, offset: 0},
  54. indent: []
  55. }
  56. ```
  57. ##### Returns
  58. `string` — Decoded `value`.
  59. ### `function warning(reason, position, code)`
  60. Error handler.
  61. ##### Context
  62. `this` refers to `warningContext` when given to `parseEntities`.
  63. ##### Parameters
  64. ###### `reason`
  65. Human-readable reason for triggering a parse error (`string`).
  66. ###### `position`
  67. Place at which the parse error occurred (`Position`).
  68. ###### `code`
  69. Identifier of reason for triggering a parse error (`number`).
  70. The following codes are used:
  71. | Code | Example | Note |
  72. | ---- | ------------------ | --------------------------------------------- |
  73. | `1` | `foo &amp bar` | Missing semicolon (named) |
  74. | `2` | `foo &#123 bar` | Missing semicolon (numeric) |
  75. | `3` | `Foo &bar baz` | Ampersand did not start a reference |
  76. | `4` | `Foo &#` | Empty reference |
  77. | `5` | `Foo &bar; baz` | Unknown entity |
  78. | `6` | `Foo € baz` | [Disallowed reference][invalid] |
  79. | `7` | `Foo � baz` | Prohibited: outside permissible unicode range |
  80. ### `function text(value, location)`
  81. Text handler.
  82. ##### Context
  83. `this` refers to `textContext` when given to `parseEntities`.
  84. ##### Parameters
  85. ###### `value`
  86. String of content (`string`).
  87. ###### `location`
  88. Location at which `value` starts and ends (`Location`).
  89. ### `function reference(value, location, source)`
  90. Character reference handler.
  91. ##### Context
  92. `this` refers to `referenceContext` when given to `parseEntities`.
  93. ##### Parameters
  94. ###### `value`
  95. Encoded character reference (`string`).
  96. ###### `location`
  97. Location at which `value` starts and ends (`Location`).
  98. ###### `source`
  99. Source of character reference (`Location`).
  100. ## Related
  101. * [`stringify-entities`](https://github.com/wooorm/stringify-entities)
  102. — Encode HTML character references
  103. * [`character-entities`](https://github.com/wooorm/character-entities)
  104. — Info on character entities
  105. * [`character-entities-html4`](https://github.com/wooorm/character-entities-html4)
  106. — Info on HTML4 character entities
  107. * [`character-entities-legacy`](https://github.com/wooorm/character-entities-legacy)
  108. — Info on legacy character entities
  109. * [`character-reference-invalid`](https://github.com/wooorm/character-reference-invalid)
  110. — Info on invalid numeric character references
  111. ## License
  112. [MIT][license] © [Titus Wormer][author]
  113. <!-- Definitions -->
  114. [build-badge]: https://img.shields.io/travis/wooorm/parse-entities.svg
  115. [build]: https://travis-ci.org/wooorm/parse-entities
  116. [coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/parse-entities.svg
  117. [coverage]: https://codecov.io/github/wooorm/parse-entities
  118. [downloads-badge]: https://img.shields.io/npm/dm/parse-entities.svg
  119. [downloads]: https://www.npmjs.com/package/parse-entities
  120. [size-badge]: https://img.shields.io/bundlephobia/minzip/parse-entities.svg
  121. [size]: https://bundlephobia.com/result?p=parse-entities
  122. [npm]: https://docs.npmjs.com/cli/install
  123. [license]: license
  124. [author]: https://wooorm.com
  125. [warning]: #function-warningreason-position-code
  126. [text]: #function-textvalue-location
  127. [reference]: #function-referencevalue-location-source
  128. [invalid]: https://github.com/wooorm/character-reference-invalid