@emmetio/css-abbreviation

中文文档
2.1.8发布于 2023/05/10MITTypeScriptESM + CJS近 30 天下载 2202.5万

Parses Emmet CSS abbreviation into AST tree

原始使用文档
文档目录3 节
  1. Usage
  2. Abbreviation syntax
  3. Operators

Emmet stylesheet abbreviation parser

Parses given Emmet stylesheet abbreviation into AST. Parsing is performed in two steps: first it tokenizes given abbreviation (useful for syntax highlighting in editors) and then tokens are analyzed and converted into AST nodes as plain, JSON-serializable objects.

Unlike in markup abbreviations, elements in stylesheet abbreviations cannot be nested and contain attributes, but allow embedded values in element names.

Usage

You can install it via npm:

npm install @emmetio/css-abbreviation

Then add it into your project:

import parse from '@emmetio/css-abbreviation';

const props = parse('p10+poa');
/* [{
    name: 'p',
    value: [{ type: 'CSSValue', value: [...] }],
    important: false
}, {
    name: 'poa',
    value: [],
    important: false
}] */

The returned result is an array of CSSProperty items: a node with name and values.

Abbreviation syntax

Emmet stylesheet abbreviation element may start with name and followed by values, optionally chained with - delimiter. In most cases, actual CSS properties doesn’t have numbers in their names (or at least they are not used in abbreviation shortcuts) so a number right after alpha characters is considered as embedded value, as well as colors starting with # character: p10, bg#fc0 etc. If implicit name/value boundary can’t be identified, you should use - as value separator: m-a, p10-20 etc.

Operators

Since CSS properties can’t be nested, the only available operator is +.

版本与发布记录

@emmetio/css-abbreviation 共发布 28 个版本,首次发布于 2017/01/25;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.1.8latest2023/05/103 年前
2.1.72023/05/023 年前
2.1.62023/03/313 年前
2.1.52023/03/313 年前
2.1.42021/03/225 年前
2.1.32021/03/225 年前

关于 @emmetio/css-abbreviation 的常见问题

@emmetio/css-abbreviation 是什么?

Parses Emmet CSS abbreviation into AST tree

如何安装 @emmetio/css-abbreviation?

在项目目录运行 npm install @emmetio/css-abbreviation,或使用 pnpm add / yarn add / bun add。

@emmetio/css-abbreviation 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@emmetio/css-abbreviation 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@emmetio/css-abbreviation 可以商用吗?

@emmetio/css-abbreviation 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@emmetio/css-abbreviation 的下载量有多少?

根据 npm 官方下载统计,@emmetio/css-abbreviation 在 2026/10/14 – 2026/11/12 这 30 天内被下载 22,024,926 次,日均约 734,164 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@emmetio/css-abbreviation 还在维护吗?

最新版本 2.1.8 发布于 2023/05/10(3 年前);至今共发布 28 个版本,其中过去 12 个月发布了 0 个;首次发布于 2017/01/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。