yoastseo
Version:
Yoast client-side content analysis
47 lines (43 loc) • 1.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.SINGLE_QUOTES_REGEX = exports.SINGLE_QUOTES_ARRAY = void 0;
exports.normalize = normalizeQuotes;
exports.normalizeDouble = normalizeDoubleQuotes;
exports.normalizeSingle = normalizeSingleQuotes;
const SINGLE_QUOTES_ARRAY = exports.SINGLE_QUOTES_ARRAY = ["'", "‘", "’", "‛", "`", "‹", "›"];
const SINGLE_QUOTES_REGEX = exports.SINGLE_QUOTES_REGEX = new RegExp("[" + SINGLE_QUOTES_ARRAY.join("") + "]", "g");
/**
* Normalizes single quotes to 'regular' quotes.
*
* @param {string} text Text to normalize.
* @returns {string} The normalized text.
*/
function normalizeSingleQuotes(text) {
return text.replace(SINGLE_QUOTES_REGEX, "'");
}
/**
* Normalizes double quotes to 'regular' quotes.
*
* @param {string} text Text to normalize.
* @returns {string} The normalized text.
*/
function normalizeDoubleQuotes(text) {
return text.replace(/[“”〝〞〟‟„『』«»]/g, "\"");
}
/**
* Normalizes quotes to 'regular' quotes.
*
* @param {string} text Text to normalize.
* @returns {string} The normalized text.
*/
function normalizeQuotes(text) {
return normalizeDoubleQuotes(normalizeSingleQuotes(text));
}
var _default = exports.default = {
normalizeSingle: normalizeSingleQuotes,
normalizeDouble: normalizeDoubleQuotes,
normalize: normalizeQuotes
};
//# sourceMappingURL=quotes.js.map