Open cx20 opened 3 years ago
wow! this is a good idea. However, would you mind if I change the position and design of the bracket icons by myself?
Yes. I'll leave it to you to decide how to implement it.
BTW, I found one problem with JS Beautifier.
In the case of #define
, when Beautifier is executed, unexpected line breaks may occur.
before)
#define X(s,l)d=s*sqrt(h);if(h>0.&&d>m&&sin(atan(d,P.y)+P.x*3.+t*l*4.)>.9)m=d;
after)
#define X(s, l) d = s * sqrt(h);
if (h > 0. && d > m && sin(atan(d, P.y) + P.x * 3. + t * l * 4.) > .9) m = d;
Unfortunately, I don't know how to solve this. I hope someone can help us.
That possibility occurred to me right away. So I haven't started on this issue, imagining that I would probably have to make the parser myself.
When I get some time, I might give it a shot!
I haven't tried it, but the following GLSL
parser may be helpful.
https://github.com/stackgl/glsl-parser
Here's one: http://evanw.github.io/glslx/
It can both format/prettify, and minify. Might be useful for writing expanded code, then hitting minify to see if it fits in a tweet, then undoing and continuing editing, etc.
This could certainly be useful.
BTW, In the future, AI may help make code easier to read. https://twitter.com/rianflo/status/1618386347810779136
I like to look at the
twigl
code on Twitter. However, much of that code is obfuscated to keep it short. How about a formatting feature to make the obfuscated code easier to read?I think
js-beautify
can be used to format the code. https://github.com/beautify-web/js-beautifyThe following is an implementation image.
before:![image](https://user-images.githubusercontent.com/1833979/118830368-d8e22980-b8f9-11eb-9842-c86915f111df.png)
after:![image](https://user-images.githubusercontent.com/1833979/118829814-67a27680-b8f9-11eb-870e-8b91f3e6f4af.png)
I think
js-beautify
can be called as follows.