Commit 331a6bca89
Unregistered key
Layout: unified · split
src/message/html.rs +24 −4
| @@ -41,6 +41,8 @@ use crate::{ | |||
| 41 | util::{join_cell_text, space_text}, | 41 | util::{join_cell_text, space_text}, |
| 42 | }; | 42 | }; |
| 43 | 43 | ||
| 44 | const QUOTE_COLOR: Color = Color::Indexed(236); | ||
| 45 | |||
| 44 | /// Generate bullet points from a [ListStyle]. | 46 | /// Generate bullet points from a [ListStyle]. |
| 45 | pub struct BulletIterator { | 47 | pub struct BulletIterator { |
| 46 | style: ListStyle, | 48 | style: ListStyle, |
| @@ -351,11 +353,14 @@ impl StyleTreeNode { | |||
| 351 | printer.push_span_nobreak(span); | 353 | printer.push_span_nobreak(span); |
| 352 | }, | 354 | }, |
| 353 | StyleTreeNode::Blockquote(child) => { | 355 | StyleTreeNode::Blockquote(child) => { |
| 354 | let mut subp = printer.sub(4); | 356 | let mut subp = printer.sub(3); |
| 355 | child.print(&mut subp, style); | 357 | child.print(&mut subp, style); |
| 356 | 358 | ||
| 357 | for mut line in subp.finish() { | 359 | for mut line in subp.finish() { |
| 358 | line.spans.insert(0, Span::styled(" ", style)); | 360 | line.spans.insert(0, Span::styled(" ", style)); |
| 361 | line.spans | ||
| 362 | .insert(0, Span::styled(line::THICK_VERTICAL, style.fg(QUOTE_COLOR))); | ||
| 363 | line.spans.insert(0, Span::styled(" ", style)); | ||
| 359 | printer.push_line(line); | 364 | printer.push_line(line); |
| 360 | } | 365 | } |
| 361 | }, | 366 | }, |
| @@ -1075,14 +1080,29 @@ pub mod tests { | |||
| 1075 | let s = "<blockquote>Hello world!</blockquote>"; | 1080 | let s = "<blockquote>Hello world!</blockquote>"; |
| 1076 | let tree = parse_matrix_html(s); | 1081 | let tree = parse_matrix_html(s); |
| 1077 | let text = tree.to_text(10, Style::default(), false, &settings); | 1082 | let text = tree.to_text(10, Style::default(), false, &settings); |
| 1083 | let style = Style::new().fg(QUOTE_COLOR); | ||
| 1078 | assert_eq!(text.lines.len(), 2); | 1084 | assert_eq!(text.lines.len(), 2); |
| 1079 | assert_eq!( | 1085 | assert_eq!( |
| 1080 | text.lines[0], | 1086 | text.lines[0], |
| 1081 | Line::from(vec![Span::raw(" "), Span::raw("Hello"), Span::raw(" ")]) | 1087 | Line::from(vec![ |
| 1088 | Span::raw(" "), | ||
| 1089 | Span::styled(line::THICK_VERTICAL, style), | ||
| 1090 | Span::raw(" "), | ||
| 1091 | Span::raw("Hello"), | ||
| 1092 | Span::raw(" "), | ||
| 1093 | Span::raw(" "), | ||
| 1094 | ]) | ||
| 1082 | ); | 1095 | ); |
| 1083 | assert_eq!( | 1096 | assert_eq!( |
| 1084 | text.lines[1], | 1097 | text.lines[1], |
| 1085 | Line::from(vec![Span::raw(" "), Span::raw("world"), Span::raw("!")]) | 1098 | Line::from(vec![ |
| 1099 | Span::raw(" "), | ||
| 1100 | Span::styled(line::THICK_VERTICAL, style), | ||
| 1101 | Span::raw(" "), | ||
| 1102 | Span::raw("world"), | ||
| 1103 | Span::raw("!"), | ||
| 1104 | Span::raw(" "), | ||
| 1105 | ]) | ||
| 1086 | ); | 1106 | ); |
| 1087 | } | 1107 | } |
| 1088 | 1108 | ||