in src/emmetHelper.ts [1046:1081]
function updateSnippets(snippetsJson: any) {
if (typeof snippetsJson === 'object' && snippetsJson) {
Object.keys(snippetsJson).forEach(syntax => {
if (!snippetsJson[syntax]['snippets']) {
return;
}
const baseSyntax = getDefaultSyntax(syntax);
let customSnippets = snippetsJson[syntax]['snippets'];
if (snippetsJson[baseSyntax] && snippetsJson[baseSyntax]['snippets'] && baseSyntax !== syntax) {
customSnippets = Object.assign({}, snippetsJson[baseSyntax]['snippets'], snippetsJson[syntax]['snippets'])
}
if (!isStyleSheet(syntax)) {
// In Emmet 2.0 all snippets should be valid abbreviations
// Convert old snippets that do not follow this format to new format
for (const snippetKey in customSnippets) {
if (customSnippets.hasOwnProperty(snippetKey)
&& customSnippets[snippetKey].startsWith('<')
&& customSnippets[snippetKey].endsWith('>')) {
customSnippets[snippetKey] = `{${customSnippets[snippetKey]}}`
}
}
} else {
const prevSnippetKeys = stylesheetCustomSnippetsKeyCache.get(syntax);
const mergedSnippetKeys = Object.assign([], prevSnippetKeys, Object.keys(customSnippets));
stylesheetCustomSnippetsKeyCache.set(syntax, mergedSnippetKeys);
}
const prevSnippetsRegistry = customSnippetsRegistry[syntax];
const newSnippets = parseSnippets(customSnippets);
const mergedSnippets = Object.assign({}, prevSnippetsRegistry, newSnippets);
const mergedSnippetKeys = Object.keys(mergedSnippets);
customSnippetsRegistry[syntax] = mergedSnippets;
});
} else {
throw new Error(localize("emmetInvalidSnippets", "Invalid snippets file. See https://code.visualstudio.com/docs/editor/emmet#_using-custom-emmet-snippets for a valid example."))
}
}