https://github.com/repcomm/csspr
Experiment CSS lexer, and bounding box renderer with no dependencies.
https://github.com/repcomm/csspr
Last synced: about 1 month ago
JSON representation
Experiment CSS lexer, and bounding box renderer with no dependencies.
- Host: GitHub
- URL: https://github.com/repcomm/csspr
- Owner: RepComm
- Created: 2021-12-12T05:09:31.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-12T20:48:46.000Z (over 4 years ago)
- Last Synced: 2025-03-23T02:44:33.454Z (about 1 year ago)
- Language: TypeScript
- Size: 117 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
Awesome Lists containing this project
README
# @repcomm/csspr
CSS Pseudo Renderer
I want to create my own CLI and graphical browser engines eventually, so this is a necessity.
This software lib has no dependencies and is intended to work with nodejs and web.
A demo can be found at index.html and index.ts
The code is imported from mod.js, which can be required from node_modules even within browser (see index.ts for example)

## State
- Lex CSS into JS objects
## Target State
- Render bounding boxes
## Intended use
- Import CSS string, file, or URL
- Supply basic DOM tree
- Call render to generate BBOXes
- Use BBOXes however you want
## Future hurdles anticipated
- This software knows nothing about font
Could be solved by using an average font metric hard coded, as well as the ability to supply font info for calculations from host software. This isn't a huge issue.
## Current API
```ts
CSSPR.load (url): Promise
```
Loads a CSS file from a URL and returns the JS object representation
Also adds to CSSPR.stylesheet.all array