dotfiles/.vscode/extensions/saviorisdead.RustyCode-0.18.0/node_modules/underscore.string/unescapeHTML.js
Cyryl Płotnicki 2f946d6200 Add .vscode
2016-09-11 10:29:13 +02:00

18 lines
593 B
JavaScript

var makeString = require('./helper/makeString');
var htmlEntities = require('./helper/htmlEntities');
module.exports = function unescapeHTML(str) {
return makeString(str).replace(/\&([^;]+);/g, function(entity, entityCode) {
var match;
if (entityCode in htmlEntities) {
return htmlEntities[entityCode];
} else if (match = entityCode.match(/^#x([\da-fA-F]+)$/)) {
return String.fromCharCode(parseInt(match[1], 16));
} else if (match = entityCode.match(/^#(\d+)$/)) {
return String.fromCharCode(~~match[1]);
} else {
return entity;
}
});
};