How to use the @emmetio/abbreviation function in @emmetio/abbreviation

To help you get started, we’ve selected a few @emmetio/abbreviation examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emmetio / emmet / src / markup / snippets.ts View on Github external
const resolve = (child: AbbreviationNode): Abbreviation | null => {
        const snippet = child.name && config.snippets[child.name];
        // A snippet in stack means circular reference.
        // It can be either a user error or a perfectly valid snippet like
        // "img": "img[src alt]/", e.g. an element with predefined shape.
        // In any case, simply stop parsing and keep element as is
        if (!snippet || stack.includes(snippet)) {
            return null;
        }

        const snippetAbbr = parse(snippet, config);
        stack.push(snippet);
        walkResolve(snippetAbbr, resolve);
        stack.pop();

        // Add attributes from current node into every top-level node of parsed abbreviation
        for (const topNode of snippetAbbr.children) {
            const from: AbbreviationAttribute[] = topNode.attributes || [];
            const to: AbbreviationAttribute[] = child.attributes || [];
            topNode.attributes = reversed ? to.concat(from) : from.concat(to);
            mergeNodes(child, topNode);
        }

        return snippetAbbr;
    };
github emmetio / emmet / src / markup / index.ts View on Github external
export default function parse(abbr: string | Abbreviation, config: Config): Abbreviation {
    if (typeof abbr === 'string') {
        let parseOpt: ParserOptions = config;
        if (config.options['jsx.enabled']) {
            parseOpt = {
                ...parseOpt,
                jsx: true
            };
        }

        abbr = abbreviation(abbr, parseOpt);
    }

    // Run abbreviation resolve in two passes:
    // 1. Map each node to snippets, which are abbreviations as well. A single snippet
    // may produce multiple nodes
    // 2. Transform every resolved node
    abbr = snippets(abbr, config);
    walk(abbr, transform, config);
    return abbr;
}
github emmetio / emmet / test / snippets.ts View on Github external
        Object.keys(xsl).forEach(k => ok(markup(xsl[k]), k));
    });

@emmetio/abbreviation

Emmet standalone abbreviation parser

MIT
Latest version published 2 years ago

Package Health Score

66 / 100
Full package analysis

Popular @emmetio/abbreviation functions