#!/usr/bin/env perl use 5.010; use warnings; use strict; use Term::ANSIColor qw(color :constants); use Text::ANSI::Util qw/ta_wrap/; sub show { my $line = shift; my $wrapped = ta_wrap($line, 30, {flindent => q[ ] x 5, slindent => q[ ] x 5 } ); say "BEFORE:"; say $line; # print unpack('H*', $_) . ' ' for split //, $line; say ''; say "AFTER:"; say $wrapped; # print unpack('H*', $_) . ' ' for split //, $wrapped; say "\n"; } show "Marley was " . BOLD . color('green') . "dead, " . RESET . "to begin with."; show "Marley was " . color('green') . "dead, " . RESET . "to begin with."; show "Marley was " . BOLD . "dead, " . RESET . "to begin with."; show "Marley was " . UNDERLINE . color('green') . "dead, to begin with. " . RESET . "There is no doubt..."; show "Marley was " . UNDERLINE . "dead, to begin with. " . RESET . "There is no doubt..."; #### BEFORE: Marley was dead, to begin with. AFTER: ## 'dead,' is bold and green but we lost the space preceding it ## Marley wasdead, to begin with. BEFORE: Marley was dead, to begin with. AFTER: ## 'dead,' is green. This is correctly rendered. ## Marley was dead, to begin with. BEFORE: Marley was dead, to begin with. AFTER: ## 'dead,' is bold. This is correctly rendered. ## Marley was dead, to begin with. BEFORE: Marley was dead, to begin with. There is no doubt... AFTER: ## 'dead, to begin with. ' is underlined/green but the preceding space was lost, and underlining between "begin" and "with" persisted across the margin ## Marley wasdead, to begin with. There is no doubt... BEFORE: Marley was dead, to begin with. There is no doubt... AFTER: ## Underlining only, but again the margin between "begin" and "with" is underlined. ## Marley was dead, to begin with. There is no doubt...