https://github.com/bramstein/css-font-parser
A parser for the CSS font values
https://github.com/bramstein/css-font-parser
Last synced: about 1 year ago
JSON representation
A parser for the CSS font values
- Host: GitHub
- URL: https://github.com/bramstein/css-font-parser
- Owner: bramstein
- Created: 2013-07-06T10:29:55.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2024-09-25T15:42:23.000Z (over 1 year ago)
- Last Synced: 2025-04-23T02:04:14.540Z (about 1 year ago)
- Language: JavaScript
- Size: 111 KB
- Stars: 26
- Watchers: 2
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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:
```bash
npm install css-font-parser
```
## Usage
```javascript
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.