Sha256: 3c92ed56aadfba6248c0917a7d035c32d7579255aba4d5149fc5406034371c7e
Contents?: true
Size: 1.1 KB
Versions: 375
Compression:
Stored size: 1.1 KB
Contents
/* global text */ /** * Determines if a given text is human friendly and interpretable * * @method isHumanInterpretable * @memberof axe.commons.text * @instance * @param {String} str text to be validated * @returns {Number} Between 0 and 1, (0 -> not interpretable, 1 -> interpretable) */ text.isHumanInterpretable = function(str) { /** * Steps: * 1) Check for single character edge cases * a) handle if character is alphanumeric & within the given icon mapping * eg: x (close), i (info) * * 3) handle unicode from astral (non bilingual multi plane) unicode, emoji & punctuations * eg: Windings font * eg: '💪' * eg: I saw a shooting 💫 * eg: ? (help), > (next arrow), < (back arrow), need help ? */ if (!str.length) { return 0; } // Step 1 const alphaNumericIconMap = [ 'x', // close 'i' // info ]; // Step 1a if (alphaNumericIconMap.includes(str)) { return 0; } // Step 2 const noUnicodeStr = text.removeUnicode(str, { emoji: true, nonBmp: true, punctuations: true }); if (!text.sanitize(noUnicodeStr)) { return 0; } return 1; };
Version data entries
375 entries across 375 versions & 1 rubygems