@@ -167,20 +167,12 @@ impl Printer for SimplePrinter<'_> {
167167 }
168168 }
169169 } else {
170+ // SimplePrinter doesn't have syntax info, so we don't strip overstrike.
171+ // This preserves raw data for plain output mode.
170172 match handle {
171- OutputHandle :: IoWrite ( handle) => {
172- // Only strip overstrike for valid UTF-8, otherwise write raw bytes
173- if let Ok ( line) = std:: str:: from_utf8 ( line_buffer) {
174- let line = strip_overstrike ( line) ;
175- handle. write_all ( line. as_bytes ( ) ) ?;
176- } else {
177- handle. write_all ( line_buffer) ?;
178- }
179- }
173+ OutputHandle :: IoWrite ( handle) => handle. write_all ( line_buffer) ?,
180174 OutputHandle :: FmtWrite ( handle) => {
181- let line = String :: from_utf8_lossy ( line_buffer) ;
182- let line = strip_overstrike ( & line) ;
183- write ! ( handle, "{line}" ) ?;
175+ write ! ( handle, "{}" , String :: from_utf8_lossy( line_buffer) ) ?;
184176 }
185177 }
186178 } ;
@@ -216,6 +208,7 @@ pub(crate) struct InteractivePrinter<'a> {
216208 background_color_highlight : Option < Color > ,
217209 consecutive_empty_lines : usize ,
218210 strip_ansi : bool ,
211+ strip_overstrike : bool ,
219212}
220213
221214impl < ' a > InteractivePrinter < ' a > {
@@ -314,6 +307,10 @@ impl<'a> InteractivePrinter<'a> {
314307 _ => false ,
315308 } ;
316309
310+ // Strip overstrike only when we have syntax highlighting (not plain text).
311+ // Overstrike is used by man pages for bold/underline formatting.
312+ let strip_overstrike = !is_plain_text;
313+
317314 Ok ( InteractivePrinter {
318315 panel_width,
319316 colors,
@@ -327,6 +324,7 @@ impl<'a> InteractivePrinter<'a> {
327324 background_color_highlight,
328325 consecutive_empty_lines : 0 ,
329326 strip_ansi,
327+ strip_overstrike,
330328 } )
331329 }
332330
@@ -640,7 +638,7 @@ impl Printer for InteractivePrinter<'_> {
640638 } ;
641639
642640 // Strip overstrike sequences (used by man pages for bold/underline).
643- if line. contains ( '\x08' ) {
641+ if self . strip_overstrike && line. contains ( '\x08' ) {
644642 line = Cow :: Owned ( strip_overstrike ( & line) . into_owned ( ) ) ;
645643 }
646644
0 commit comments