piotrmurach / pastel

Terminal output styling with intuitive and clean API.
https://ttytoolkit.org
MIT License
640 stars 23 forks source link

undecorate does not recognize nested color in style #24

Closed pjvleeuwen closed 4 years ago

pjvleeuwen commented 4 years ago

Describe the problem

Undecorate does not recognize nested colors/styles.

Steps to reproduce the problem

require 'pastel'
require 'strscan'
pastel = ::Pastel.new
pastel.new.undecorate(pastel.bold('FIRST' + pastel.blue('SECOND') + 'THIRD'))[1]
# {:foreground=>:blue, :text=>"SECOND"}
pastel.new.undecorate(pastel.on_yellow('FIRST' + pastel.blue('SECOND') + 'THIRD'))[1]
# {:foreground=>:blue, :text=>"SECOND"}
pastel.new.undecorate(pastel.on_yellow('FIRST' + pastel.bold('SECOND') + 'THIRD'))[1]
# {:style=>:bold, :text=>"SECOND"}

Actual behaviour

The nested part ('SECOND') does not not retain the wrapping color/style.

Expected behaviour

Expected the undecorate to recognize the nested valid styles.

Describe your environment

pjvleeuwen commented 4 years ago

nice, thanks!

piotrmurach commented 4 years ago

Released v0.8.0. Next, I'll update all the tty gems that rely on pastel and relax their version restrictions.