Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SilentImp opened this issue Dec 12, 2018 · 7 comments
Open

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

SilentImp opened this issue Dec 12, 2018 · 7 comments
Assignees
Labels

Comments

@SilentImp
Copy link

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
Copy link
Member

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 .

@Glavin001 Glavin001 self-assigned this Dec 12, 2018
@SilentImp
Copy link
Author

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
Copy link
Contributor

@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
Copy link
Author

@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
Copy link
Contributor

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
Copy link
Author

Thank you!

@Glavin001 Glavin001 assigned stevenzeck and SilentImp and unassigned Glavin001 Dec 14, 2018
@Glavin001 Glavin001 changed the title May I use unibeautify from node.js script without using cli? Add documentation to README for using Unibeautify as Node.js API Dec 14, 2018
@Glavin001
Copy link
Member

@SilentImp : Pull Requests improving README are very welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants