blessings
blessings copied to clipboard
Support (and tests) for tuples with nested styles
In some cases, it would be nice if we could "nest" styles by passing tuples, like so:
# creates a red phrase with some bold words in the middle:
t.red('This is ', t.bold('extremely important'), ' information!')
# deeper nesting of styles (green, then bold, then underline, and back out)
t.green('foo', t.bold('bar', t.underline('baz'), 'herp'), 'derp')
I've added tests with and without TTY, and so far it seems robust. Thoughts?
Hi Erik, I just noticed this PR is languishing. Is there anything i can do to make it more palatable, or is this just out of scope for the tool?
My fault; I just got distracted with other libraries. I'll try to have a look after PyCon. Sorry!
In general I like this, but only because there's no nice way of doing this with a single string format.
The fact that you reset just what's in the nest, IMO, is the value add.
Would be nice to be able to use your fancy resetting to let something like this work:
"{t.red}This {t.bold}is important{t.no_bold}!".format(t=terminal)
but that's another pull request for another time...