GithubHelp home page GithubHelp logo

Comments (3)

nodanaonlyzuul avatar nodanaonlyzuul commented on June 17, 2024

I'm able to replicate this. It happens with any piping.

For example:

$ asciiart -c flanders.jpg
<COLOR ART HERE>

$ asciiart -c flanders.jpg | grep =
<white "="s here>

It's been a LOOONNNNNGGG time since this gem has gotten any attention so thanks for the issue.
I'm not proud of some of this code but....

-c (with text output relies on the rainbow gem (v 2.0.0).
I see Rainbow has been updated to 3.0.0 since I originally wrote asciiart and maybe they're aware of it...or maybe it's a limitation of colored output? I'm no expect but I made a small test using Rainbow 2.0.0

#rainbowtext.rb
require 'rainbow'
require 'rainbow/ext/string'

puts "Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
  aliqua. Ut enim ad minim veniam, quis ".color(:yellow)
$ ruby rainbowtest.rb
<YELLOW TEXT HERE>

$ ruby rainbowtest.rb | grep m
<white m's here>

When I have some freetime - I can experiment with newer versions of Rainbow, but if you have a moment you could try it to? The exact line is here.

You'd need to:

  1. Bump the gemspec to newer version of Rainbow
  2. Use newer syntax if needed.

from asciiart.

tpapastylianou avatar tpapastylianou commented on June 17, 2024

Thanks, Stephen!

I had a look inside rainbow.rb. It contains this line:

  self.enabled = true if ENV['CLICOLOR_FORCE'] == '1'

Therefore, this works as intended:

CLICOLOR_FORCE=1 asciiart -c imagefile.png | less -R

:)

EDIT: Furthermore, it seems that this is the main way to get rainbow to behave in this way. So while there's no programmatic fix per se, maybe an update to the manpage to point this out might be useful to future users :)

from asciiart.

nodanaonlyzuul avatar nodanaonlyzuul commented on June 17, 2024

For sure - this has been a fun introduction (for me at least) about how color is managed in terminals. I've created #9 and will take a swing at it!

EDIT: Thanks for doing the footwork in rainbows @tpapastylianou !

from asciiart.

Related Issues (9)

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.