1.0.0 • Published 6 years ago
parseme v1.0.0
parseme
A tiny prettyfier for HTML and CSS
- Install
npm install parseme
- Usage
You need to include the file(s) of the language(s) to use.
import parseme from 'parseme';
import html from 'parseme/languages/html';
parseme.init({
language: 'html',
selector: '.parseme'
});
parseme.load();
- Generate parser from grammar
pegjs ./src/parsers/html.pegjs
- Run depelopment watch
npm run dev
Open browser pointing to http://localhost:8383/example/
- Run tests
npm run test
- Build dist
npm run build
- Upload build
The build must be generated before (point 6)
npm publish
- List of methods
- init: sets initial options.
- language: 'html', 'css' or 'json'
- parser: function to parse the code. (only to use custom parser)
- prettier: prettier to use. (only to use custor prettier)
- selector: CSS selector to use in load method.
- compilation: if true uses the parser, when false uses the lexer
- lines: when true show line numbers.
- load: formats every selector set in initial options.
- parse(code, options): parses the received code with the optional options.
- format(code, options): formats the received code with the optional options.
- Create new language
- Create language in src/languages this will need:
- create grammar in src/parsers and generate parser (point 3)
- create prettier in src/prettiers
- create lexer in src/languages
- Adds language config in webpack.config.js to generate the new output file.
1.0.0
6 years ago