emmet
emmet copied to clipboard
parseSnippets, SnippetsMap, and syntaxes not exported from index.ts
I noticed that parseSnippets, SnippetsMap
, and syntaxes
, which are all defined in config.ts
, aren't exported out through index.ts
.
Considering that parseStylesheetSnippets
is exported, and that the constant syntaxes
isn't used anywhere within the project itself, I'm wondering whether at least parseSnippets
and syntaxes
should be exported?
These are internal features mostly: basically, you shouldn’t use them directly, you should pass raw snippets directly to expand()
method and Emmet internals will parse them and store into cache
property to skip re-parse on next invocation.
Although in practice, cache
doesn’t work properly in some cases (found it in ST plugin) so it needs further investigation and fixes.
It makes sense that raw snippets should be passed to the expand()
function. However, the only time I see parseSnippets()
being called is when defining syntaxConfig
within config.ts
. Therefore, a unit test such as this fails:
it('custom snippets with pipe', () => {
const snippets = {
'atest|btest': 'br'
};
equal(expand('atest', { snippets }), '<br>');
})
Also, I think the constant syntaxes
should be exported, since otherwise how would downstream dependencies easily keep track of the following:
- Whether the syntax is supported by Emmet?
- Whether the syntax is a stylesheet one or a markup one (that is supported by Emmet)?
I'll have to look into how the cache works a bit more, as the current VS Code implementation is not using the Emmet cache.