Unibeautify / unibeautify

One Beautifier to rule them all, One Beautifier to clean them, One Beautifier to bring them all and in the darkness sheen them
https://unibeautify.com/
MIT License
544 stars 41 forks source link

Add documentation to README for using Unibeautify as Node.js API #214

Open SilentImp opened 5 years ago

SilentImp commented 5 years ago

Is your feature request related to a problem? Please describe. Hi, I am parsing frontend articles and want to beautify snippets of code inside. But I have no idea how to use it from node.js on a string of code.

Describe the solution you'd like npm package with api would be awesome. how did you do it in the playground?

Describe alternatives you've considered prettier package for example. problem is that I have no idea about snippets language and it fails on some nasty piece of code from time to time.

Additional context

Glavin001 commented 5 years ago

Hi, I am parsing frontend articles and want to beautify snippets of code inside.

Unfortunately, Unibeautify must run within Node.js on a server, it does not work within the browser.

npm package with api would be awesome.

Unibeautify is already a npm package: https://yarnpkg.com/en/package/unibeautify 🎉

it fails on some nasty piece of code from time to time.

Can you provide some more details of what you're doing? Ideally, a repository we could build ourselves locally and following https://stackoverflow.com/help/mcve .

SilentImp commented 5 years ago

Unfortunately, Unibeautify must run within Node.js on a server, it does not work within the browser.

Yes, I want to run it exactly that way. On node.js server. Not in the browser.

Unibeautify is already a npm package

It provides CLI utility. I need to run it from my node.js script without using CLI. Is it possible?

Can you provide some more details of what you're doing?

That was about https://www.npmjs.com/package/prettier package. I actually may, but I have a filling you somehow got me wrong.

stevenzeck commented 5 years ago

@SilentImp I think what you want is https://www.npmjs.com/package/unibeautify. You can call the methods in there using node. Docs here: https://api.unibeautify.com/

SilentImp commented 5 years ago

@stevenzeck oh, look like you are right. Main problem was (is) documentation and lack of examples in the main readme.md.

If you also add the link to an example of how I may beautify string of code — I will be totally happy. But thank you kindly in any case.

stevenzeck commented 5 years ago

https://github.com/Unibeautify/vscode/blob/master/src/EditProvider.ts#L52-L86 is a good example. Mainly https://github.com/Unibeautify/vscode/blob/master/src/EditProvider.ts#L80-L83, you'll see that's where unibeautify calls the beautify method with the data (text, language, options, etc).

SilentImp commented 5 years ago

Thank you!

Glavin001 commented 5 years ago

@SilentImp : Pull Requests improving README are very welcome!