0
Fork 0
mirror of https://github.com/penpot/penpot-plugins.git synced 2025-01-09 08:22:09 -05:00
penpot-plugins/libs/plugins-data-parser
2024-03-04 11:06:11 +01:00
..
src fix(parser): removed useless IdData type 2024-03-04 11:06:11 +01:00
.eslintrc.json feat: parser library 2024-03-04 08:46:07 +01:00
package.json feat: parser library 2024-03-04 08:46:07 +01:00
project.json feat: parser library 2024-03-04 08:46:07 +01:00
README.md fix(parser): removed useless IdData type 2024-03-04 11:06:11 +01:00
tsconfig.json feat: parser library 2024-03-04 08:46:07 +01:00
tsconfig.lib.json feat: parser library 2024-03-04 08:46:07 +01:00
vite.config.ts feat: parser library 2024-03-04 08:46:07 +01:00

Parser

This library includes a parse() funtion and some parsed models like ParsedFile or ParsedPage.

The parse function cleans up and transforms a penpot object into a more typescript friendly object. It returns a ParsedData object that can be casted as ParsedFile or ParsedPage. Note that ParsedData is the parent interface and includes all ParsedFile and ParsedPage properties.

Most of the properties are optional and may or may not be present in your result, you should access them with care.

Use

Import the parse function and the desired models from plugins data parser.

Example:

import { parse, ParsedFile } from 'plugins-parser';

[...]

const parsedFile: ParsedFile = parse(file);
console.log(parsedFile.data.colors?.[0]?.color);

[...]