css-font-parser

A parser for the CSS font value

BSD-3-Clause 8 个版本
安装
npm install css-font-parser
yarn add css-font-parser
pnpm add css-font-parser
bun add css-font-parser
README

CSS font value parser

A simple parser for parsing CSS font values in JavaScript. It has a parser for the font shorthand syntax and the font-family syntax.

Installation

You can install the parser using:

npm install css-font-parser

Usage

import { parseFont, parseFontFamily } from 'css-font-parser';

parseFont('15px sans-serif');

> {
>   'font-family': ['sans-serif'],
>   'font-size': '15px'
> }

parseFont('15px/18px "Neue Helvetica", Helvetica, sans-serif');

> {
>   'font-family': ['Neue Helvetica', 'Helvetica', 'sans-serif'],
>   'font-size': '15px',
>   'line-height': '18px'
> }

parseFontFamily('"Neue Helvetica", Helvetica, system-ui, sans-serif');

> ['Neue Helvetica', 'Helvetica', 'system-ui', 'sans-serif']

License

Licensed under the three-clause BSD license.

版本列表
2.0.1 2024-10-01
2.0.0 2022-08-19
1.0.1 2022-08-17
0.3.0 2020-02-17
0.2.3 2017-09-14
0.2.2 2017-09-07
0.2.1 2015-11-17
0.2.0 2013-07-17