dotfiles/.vscode/extensions/saviorisdead.RustyCode-0.18.0/node_modules/underscore.string/unescapeHTML.js

19 lines
593 B
JavaScript
Raw Normal View History

2016-09-11 09:29:13 +01:00
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;
}
});
};