yoastseo
Version:
Yoast client-side content analysis
21 lines (17 loc) • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.htmlEntitiesRegex = exports.htmlEntities = exports.hashedHtmlEntitiesRegexStart = exports.hashedHtmlEntitiesRegexEnd = exports.hashedHtmlEntities = void 0;
// Contains 1) special characters usually converted into HTML entities (cf. _wp_specialchars).
// And 2) their corresponding HTML entities, stripped from the initial ampersand (e.g. 'lt;' instead of '<').
const htmlEntities = exports.htmlEntities = new Map([["amp;", "&"], ["lt;", "<"], ["gt;", ">"], ["quot;", '"'], ["apos;", "'"], ["ndash;", "–"], ["mdash;", "—"], ["copy;", "©"], ["reg;", "®"], ["trade;", "™"], ["pound;", "£"], ["yen;", "¥"], ["euro;", "€"], ["dollar;", "$"], ["deg;", "°"], ["asymp;", "≈"], ["ne;", "≠"], ["nbsp;", " "]]);
// Regex to find all HTML entities.
const htmlEntitiesRegex = exports.htmlEntitiesRegex = new RegExp("&(" + [...htmlEntities.keys()].join("|") + ")", "ig");
// Contains special characters along with their hashed HTML entities (e.g. '#amp;' instead of '&' for the ampersand character '&').
const hashedHtmlEntities = exports.hashedHtmlEntities = new Map();
htmlEntities.forEach((value, key) => hashedHtmlEntities.set("#" + key, value));
// Regex to find hashed HTML entities attached to the beginning (hashedHtmlEntitiesRegexStart) or to the end of a string (hashedHtmlEntitiesRegexEnd).
const hashedHtmlEntitiesRegexStart = exports.hashedHtmlEntitiesRegexStart = new RegExp("^(" + [...hashedHtmlEntities.keys()].join("|") + ")");
const hashedHtmlEntitiesRegexEnd = exports.hashedHtmlEntitiesRegexEnd = new RegExp("(" + [...hashedHtmlEntities.keys()].join("|") + ")$");
//# sourceMappingURL=htmlEntities.js.map