summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 06a9965..495c971 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -381,6 +381,21 @@ impl SpecialRender {
}
}
+fn max_line_length() -> usize {
+ let (terminal_width, _) = crossterm::terminal::size().unwrap_or((80, 24));
+ (terminal_width as usize - 2).min(80)
+}
+
+fn render_text(text: &str) -> String {
+ let mut ansi_printer = AnsiPrinter::new(max_line_length());
+
+ ansi_printer.pause_style();
+ ansi_printer.prefix();
+ ansi_printer.resume_style();
+ ansi_printer.text(text);
+ ansi_printer.out
+}
+
fn markdown(text: &str) -> String {
let SpecialRender {
fancy,
@@ -427,8 +442,7 @@ fn markdown(text: &str) -> String {
let mut list_numbers = Vec::new();
- let (terminal_width, _) = crossterm::terminal::size().unwrap_or((80, 24));
- let max_line_len = (terminal_width as usize - 2).min(80);
+ let max_line_len = max_line_length();
let mut links = Vec::new();