Comments (6)
Hi @rjmunro! Thanks for reporting this :)
I'll have a think about the best way to approach this.
It would also be good if the error message could be improved, by giving a line number and the error character in \u00xx format if it is non printable.
That sounds like a good idea; I'll add that to the list of things to implement :)
from gron.
hi guys.
i'm strongly against the idea that ungron
would have the responsibility to ignore escape codes.
it's a good practice to let the output producer component to check who is on the other end of the pipe (usually by isatty()
) and colorize accordingly.
I suggest to add the isatty()
-like condition in gron
to solve this issue.
cheers.
from gron.
@bAndie91 gron already has this, but this means you never any syntax colouring if you want to use gron with grep, which is kind of the main point. So it has an option to force colouring to be on (-c
), which is great.
What's the problem with ignoring escape codes? It should only be a small adjustment to the parser, but it's a huge saving when you need it.
from gron.
@rjmunro ye sorry i did not compare the current codebase to the version of the age of this ticket, just checked that the ticket is open. i'm glad that gron tests for isatty and stuff. i'm also ok with force coloring switch, grep and ls have it too.
stripping escape sequence (as ungron would do) is an other topic. i just have not seen this behaviour in any let's say standard unix tool. and again, stripping by ungron and auto-no-coloring by gron solves the same problem. my other thought on this topic is that auto-no-coloring by gron is more deterministic since it knows what is data and what is styling, while on the other side of the pipe it's not so unambiguous to tell what was intended to be the part of the data and what not.
if I designed someting where terminal escape sequences were flowing though the pipe I'd put an additional component in the pipe whiches only responsibility is to strip the codes (like i sometimes sentenced do it with programms which misregard isatty, eg. colorful-tool | sed -e 's/\x1B...something...//g' | egrep ^xyz
).
thanks for your attention.
from gron.
This started because the error message you get for passing gron -c
to ungron
was really unhelpful (ungron failed for ``: invalid statement
), and stumped me for several minutes. I don't mind that much about auto-stripping colour if we can fix that to be more explanative - e.g. by having it escape the characters with the error in the error message.
from gron.
i agree ungron may indicate where the parse error happened by a snippet with escaped control chars in it - if you mean it.
from gron.
Related Issues (20)
- --no-sort option is unstable HOT 5
- Ungron doesn't respect --no-sort option HOT 1
- Output format HOT 12
- more tollerance when parsing
- Remove this HOT 1
- Export functions? HOT 1
- asdf gron
- Colour - Support Highlighting when Ungronning from grep.
- Bash completions HOT 1
- Pager? HOT 1
- Feature request HOT 3
- Inconsistency in ungron for invalid inputs HOT 1
- Add github topics? HOT 1
- `gron URL` doesn't use the proxy defined in environment HOT 2
- Latest release
- ungron is slow and leaky HOT 7
- Binary builds broken?? HOT 4
- Add release for armv6l
- Special-case `new Array()` and `new Object`
- v0.7.1 does not report its own version HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gron.