.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / parse-entities / decode-entity.browser.js
1 'use strict'
2
3 /* eslint-env browser */
4
5 var el
6
7 var semicolon = 59 //  ';'
8
9 module.exports = decodeEntity
10
11 function decodeEntity(characters) {
12   var entity = '&' + characters + ';'
13   var char
14
15   el = el || document.createElement('i')
16   el.innerHTML = entity
17   char = el.textContent
18
19   // Some entities do not require the closing semicolon (`&not` - for instance),
20   // which leads to situations where parsing the assumed entity of &notit; will
21   // result in the string `¬it;`.  When we encounter a trailing semicolon after
22   // parsing and the entity to decode was not a semicolon (`;`), we can
23   // assume that the matching was incomplete
24   if (char.charCodeAt(char.length - 1) === semicolon && characters !== 'semi') {
25     return false
26   }
27
28   // If the decoded string is equal to the input, the entity was not valid
29   return char === entity ? false : char
30 }