Support (and tests) for tuples with nested styles#45
Conversation
|
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! |
There was a problem hiding this comment.
Can you make this rst happy? (double the colons) add a new line after 478 and make sure 479 is 4 spaces in.
It's a nit that I'd do myself, but I have another request below...
|
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: but that's another pull request for another time... |
There was a problem hiding this comment.
What a crazy idea. It's backtracking, but I do believe it'll work. This lets us compose formatted strings without having to go down the road of assembling a syntax tree and keeping it off to the side someplace. This is a very promising functionality/complexity tradeoff. I'm impressed.
@jimallman brings us this convenience of allowing existing strings to be joined as a call parameter argument to a FormattingString, allowing nestation: This was rejected upstream as erikrose#45 ```python t.red('This is ', t.bold('extremely important'), ' information!') t.green('foo', t.bold('bar', t.underline('baz'), 'herp'), 'derp') ```
In some cases, it would be nice if we could "nest" styles by passing tuples, like so:
I've added tests with and without TTY, and so far it seems robust. Thoughts?