in src/emmetHelper.ts [486:520]
export function isAbbreviationValid(syntax: string, abbreviation: string): boolean {
if (!abbreviation) {
return false;
}
if (isStyleSheet(syntax)) {
if (abbreviation.includes('#')) {
if (abbreviation.startsWith('#')) {
const hexColorRegex = /^#[\d,a-f,A-F]{1,6}$/;
return hexColorRegex.test(abbreviation);
} else if (commonlyUsedTags.includes(abbreviation.substring(0, abbreviation.indexOf('#')))) {
return false;
}
}
return cssAbbreviationRegex.test(abbreviation);
}
if (abbreviation.startsWith('!')) {
return !/[^!]/.test(abbreviation);
}
// Its common for users to type (sometextinsidebrackets), this should not be treated as an abbreviation
// Grouping in abbreviation is valid only if it's inside a text node or preceeded/succeeded with one of the symbols for nesting, sibling, repeater or climb up
// Also, cases such as `span[onclick="alert();"]` are valid
if ((/\(/.test(abbreviation) || /\)/.test(abbreviation))
&& !/\{[^\}\{]*[\(\)]+[^\}\{]*\}(?:[>\+\*\^]|$)/.test(abbreviation)
&& !/\(.*\)[>\+\*\^]/.test(abbreviation)
&& !/\[[^\[\]\(\)]+=".*"\]/.test(abbreviation)
&& !/[>\+\*\^]\(.*\)/.test(abbreviation)) {
return false;
}
if (syntax === 'jsx') {
return (jsxAbbreviationStartRegex.test(abbreviation) && htmlAbbreviationRegex.test(abbreviation));
}
return (htmlAbbreviationStartRegex.test(abbreviation) && htmlAbbreviationRegex.test(abbreviation));
}