Coder Social home page Coder Social logo

Comments (6)

tomnomnom avatar tomnomnom commented on June 2, 2024

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.

bAndie91 avatar bAndie91 commented on June 2, 2024

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.

rjmunro avatar rjmunro commented on June 2, 2024

@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.

bAndie91 avatar bAndie91 commented on June 2, 2024

@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.

rjmunro avatar rjmunro commented on June 2, 2024

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.

bAndie91 avatar bAndie91 commented on June 2, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.