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.

association.js 1.1KB

123456789101112131415161718192021222324252627282930
  1. module.exports = association
  2. var decode = require('parse-entities/decode-entity')
  3. var characterEscape = /\\([!-/:-@[-`{-~])/g
  4. var characterReference = /&(#(\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi
  5. // The `label` of an association is the string value: character escapes and
  6. // references work, and casing is intact.
  7. // The `identifier` is used to match one association to another: controversially,
  8. // character escapes and references don’t work in this matching: `©` does
  9. // not match `©`, and `\+` does not match `+`.
  10. // But casing is ignored (and whitespace) is trimmed and collapsed: ` A\nb`
  11. // matches `a b`.
  12. // So, we do prefer the label when figuring out how we’re going to serialize:
  13. // it has whitespace, casing, and we can ignore most useless character escapes
  14. // and all character references.
  15. function association(node) {
  16. if (node.label || !node.identifier) {
  17. return node.label || ''
  18. }
  19. return node.identifier
  20. .replace(characterEscape, '$1')
  21. .replace(characterReference, decodeIfPossible)
  22. }
  23. function decodeIfPossible($0, $1) {
  24. return decode($1) || $0
  25. }