|
--- html2text.rs 2024-10-15 21:16:11.842870135 +0700 |
|
+++ html2text-patched.rs 2024-10-16 01:35:36.806983491 +0700 |
|
@@ -26,42 +26,44 @@ |
|
for annotation in annotations.iter() { |
|
match annotation { |
|
Default => {} |
|
- Link(_) => { |
|
- start.push(format!("{}", termion::style::Underline)); |
|
- finish.push(format!("{}", termion::style::Reset)); |
|
+ Link(url) => { |
|
+ start.push(format!("{}{}", Fg(AnsiValue(153)), termion::style::Underline)); |
|
+ start.push(format!("\x1B]8;;{}\x1B\\", url)); |
|
+ finish.push(format!("\x1B]8;;\x1B\\")); |
|
+ finish.push(format!("{}{}", Fg(White), termion::style::NoUnderline)); |
|
} |
|
Image(_) => { |
|
if !have_explicit_colour { |
|
- start.push(format!("{}", Fg(Blue))); |
|
- finish.push(format!("{}", Fg(Reset))); |
|
+ start.push(format!("{}{}", Fg(AnsiValue(225)), termion::style::Italic)); |
|
+ finish.push(format!("{}{}", Fg(White), termion::style::NoItalic)); |
|
} |
|
} |
|
Emphasis => { |
|
- start.push(format!("{}", termion::style::Bold)); |
|
- finish.push(format!("{}", termion::style::Reset)); |
|
+ start.push(format!("{}", termion::style::Italic)); |
|
+ finish.push(format!("{}", termion::style::NoItalic)); |
|
} |
|
Strong => { |
|
if !have_explicit_colour { |
|
- start.push(format!("{}", Fg(LightYellow))); |
|
- finish.push(format!("{}", Fg(Reset))); |
|
+ start.push(format!("{}", termion::style::Bold)); |
|
+ finish.push(format!("{}", termion::style::NoBold)); |
|
} |
|
} |
|
Strikeout => { |
|
if !have_explicit_colour { |
|
- start.push(format!("{}", Fg(LightBlack))); |
|
- finish.push(format!("{}", Fg(Reset))); |
|
+ start.push(format!("{}{}", Fg(AnsiValue(7)), termion::style::CrossedOut)); |
|
+ finish.push(format!("{}{}", Fg(White), termion::style::NoCrossedOut)); |
|
} |
|
} |
|
Code => { |
|
if !have_explicit_colour { |
|
- start.push(format!("{}", Fg(Blue))); |
|
- finish.push(format!("{}", Fg(Reset))); |
|
+ start.push(format!("{}{}", Bg(AnsiValue(25)), Fg(AnsiValue(222)))); |
|
+ finish.push(format!("{}{}", Bg(Reset) ,Fg(White))); |
|
} |
|
} |
|
Preformat(_) => { |
|
if !have_explicit_colour { |
|
- start.push(format!("{}", Fg(Blue))); |
|
- finish.push(format!("{}", Fg(Reset))); |
|
+ start.push(format!("{}{}", Bg(AnsiValue(25)), Fg(AnsiValue(229)))); |
|
+ finish.push(format!("{}{}", Bg(Reset), Fg(White))); |
|
} |
|
} |
|
Colour(c) => { |
|
@@ -92,6 +94,8 @@ |
|
} |
|
|
|
fn update_config<T: TextDecorator>(mut config: Config<T>, flags: &Flags) -> Config<T> { |
|
+ config = config.raw_mode(true); |
|
+ config = config.no_link_wrapping(); |
|
if let Some(wrap_width) = flags.wrap_width { |
|
config = config.max_wrap_width(wrap_width); |
|
} |
Updated to work with rust-html2text new release 0.13.0-alpha.0.