emmet icon indicating copy to clipboard operation
emmet copied to clipboard

parseSnippets, SnippetsMap, and syntaxes not exported from index.ts

Open rzhao271 opened this issue 3 years ago • 2 comments

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?

rzhao271 avatar Oct 20 '20 22:10 rzhao271

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.

sergeche avatar Oct 21 '20 19:10 sergeche

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:

  1. Whether the syntax is supported by Emmet?
  2. 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.

rzhao271 avatar Oct 22 '20 21:10 rzhao271