Describe the bug
When parsing markup, the parser tries to optimize-out redundant sequences. This works when two PLAIN tokens share the exact same sequences, however when the sequence has a new element added it is detected as a wholly unique one, duplicating the sequence for no effect.
To Reproduce
>> import pytermgui as ptg
>> ptg.markup.parse("[bold 141]First [bold 141 italic]First but italic")
'\x1b[1m\x1b[38;5;141mFirst \x1b[1m\x1b[38;5;141m\x1b[3mFirst but italic\x1b[0m'
Expected behavior
The output of the above call should be \x1b[1m\x1b[38;5;141mFirst \x1b[3mFirst but italic\x1b[0m.
Possible cause
The "optimizer" part of the parser checks for strict equality, not partial.
Possible solution
Either fixing the possible cause, or leaving it be and running it through an optimize method. That could hinder speed, so the first option is preferred.
Describe the bug When parsing markup, the parser tries to optimize-out redundant sequences. This works when two
PLAIN
tokens share the exact same sequences, however when the sequence has a new element added it is detected as a wholly unique one, duplicating the sequence for no effect.To Reproduce
Expected behavior The output of the above call should be
\x1b[1m\x1b[38;5;141mFirst \x1b[3mFirst but italic\x1b[0m
.System information
Possible cause The "optimizer" part of the parser checks for strict equality, not partial.
Possible solution Either fixing the possible cause, or leaving it be and running it through an
optimize
method. That could hinder speed, so the first option is preferred.