prettier-core-printer
v3.4.0
Published
This package extracts the just necessary files from prettier [GitHub repo](https://github.com/prettier/prettier/tree/main/src) to enable printing. It doesn't include parser or other components from prettier.
Downloads
6
Readme
Overview
This package extracts the just necessary files from prettier GitHub repo to enable printing. It doesn't include parser or other components from prettier.
Here is a simple example of how this repo could be used (from test/dev/devTest.js)
import {group, indent, line} from '../../dist/document/builders.js';
import {printDocToString} from '../../dist/document/printer.js';
function testPrinter() {
console.log(
printDocToString(group(['(*', indent([line, 'Prettier:', line, 'Opinionated,', line, 'Code,', line, 'Formatter']), line, '*)']), {printWidth: 80})
.formatted
);
}
testPrinter();
Why?
We wanted to build a formatter Sfsql language (superset of Salesforce SOQL/SOSL language), and we wanted something to be able to generate the formatted source. We have our own parser and so didn't want to include a full prettier package which adds around 5+mb to the package. So we extracted just the files needed to print the Doc tokens.
Use Cases
You can use it for anything you like as long you can create Doc tokens for your text, you can build a printer.
License
It uses the same license as Prettier, which is MIT. All copyrights belong to the prettier repo.