UNPKG

@riotjs/parser

Version:

The parser for Riot tags

42 lines (39 loc) 1.12 kB
/** * Matches the start of valid tags names; used with the first 2 chars after the `'<'`. * @constant * @private */ export const TAG_2C = /^(?:\/[a-zA-Z]|[a-zA-Z][^\s>/]?)/ /** * Matches valid tags names AFTER the validation with `TAG_2C`. * $1: tag name including any `'/'`, $2: non self-closing brace (`>`) w/o attributes. * @constant * @private */ export const TAG_NAME = /(\/?[^\s>/]+)\s*(>)?/g /** * Matches an attribute name-value pair (both can be empty). * $1: attribute name, $2: value including any quotes. * @constant * @private */ export const ATTR_START = /(\S[^>/=\s]*)(?:\s*=\s*([^>/])?)?/g /** * Matches the spread operator * it will be used for the spread attributes * @type {RegExp} */ export const SPREAD_OPERATOR = /\.\.\./ /** * Matches the closing tag of a `script` and `style` block. * Used by parseText fo find the end of the block. * @constant * @private */ export const RE_SCRYLE = { script: /<\/script\s*>/gi, style: /<\/style\s*>/gi, textarea: /<\/textarea\s*>/gi, } // Do not touch text content inside this tags export const RAW_TAGS = /^\/?(?:pre|textarea)$/