blob: c44810a73ebad44170083457dfd42afed316ff3c [file] [log] [blame]
/*!
* XRegExp Unicode Properties 4.3.0
* <xregexp.com>
* Steven Levithan (c) 2012-present MIT License
* Unicode data by Mathias Bynens <mathiasbynens.be>
*/
import properties from '../../tools/output/properties';
export default (XRegExp) => {
/**
* Adds properties to meet the UTS #18 Level 1 RL1.2 requirements for Unicode regex support. See
* <http://unicode.org/reports/tr18/#RL1.2>. Following are definitions of these properties from
* UAX #44 <http://unicode.org/reports/tr44/>:
*
* - Alphabetic
* Characters with the Alphabetic property. Generated from: Lowercase + Uppercase + Lt + Lm +
* Lo + Nl + Other_Alphabetic.
*
* - Default_Ignorable_Code_Point
* For programmatic determination of default ignorable code points. New characters that should
* be ignored in rendering (unless explicitly supported) will be assigned in these ranges,
* permitting programs to correctly handle the default rendering of such characters when not
* otherwise supported.
*
* - Lowercase
* Characters with the Lowercase property. Generated from: Ll + Other_Lowercase.
*
* - Noncharacter_Code_Point
* Code points permanently reserved for internal use.
*
* - Uppercase
* Characters with the Uppercase property. Generated from: Lu + Other_Uppercase.
*
* - White_Space
* Spaces, separator characters and other control characters which should be treated by
* programming languages as "white space" for the purpose of parsing elements.
*
* The properties ASCII, Any, and Assigned are also included but are not defined in UAX #44. UTS
* #18 RL1.2 additionally requires support for Unicode scripts and general categories. These are
* included in XRegExp's Unicode Categories and Unicode Scripts addons.
*
* Token names are case insensitive, and any spaces, hyphens, and underscores are ignored.
*
* Uses Unicode 12.1.0.
*
* @requires XRegExp, Unicode Base
*/
if (!XRegExp.addUnicodeData) {
throw new ReferenceError('Unicode Base must be loaded before Unicode Properties');
}
const unicodeData = properties;
// Add non-generated data
unicodeData.push({
name: 'Assigned',
// Since this is defined as the inverse of Unicode category Cn (Unassigned), the Unicode
// Categories addon is required to use this property
inverseOf: 'Cn'
});
XRegExp.addUnicodeData(unicodeData);
};