Commit 331a6bca89

331a6bca896a51844197f96f02f7288d04ea2191

parent: 963ce3c7c2

Unregistered key

vaw <git@nlih.de> · 2025-07-23 00:26 UTC
committer: <noreply@github.com>

Make blockquotes in message visually distict (#466)

Layout: unified · split

src/message/html.rs +24 −4
@@ -41,6 +41,8 @@ use crate::{
4141 util::{join_cell_text, space_text},
4242};
4343
44const QUOTE_COLOR: Color = Color::Indexed(236);
45
4446/// Generate bullet points from a [ListStyle].
4547pub struct BulletIterator {
4648 style: ListStyle,
@@ -351,11 +353,14 @@ impl StyleTreeNode {
351353 printer.push_span_nobreak(span);
352354 },
353355 StyleTreeNode::Blockquote(child) => {
354 let mut subp = printer.sub(4);
356 let mut subp = printer.sub(3);
355357 child.print(&mut subp, style);
356358
357359 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));
359364 printer.push_line(line);
360365 }
361366 },
@@ -1075,14 +1080,29 @@ pub mod tests {
10751080 let s = "<blockquote>Hello world!</blockquote>";
10761081 let tree = parse_matrix_html(s);
10771082 let text = tree.to_text(10, Style::default(), false, &settings);
1083 let style = Style::new().fg(QUOTE_COLOR);
10781084 assert_eq!(text.lines.len(), 2);
10791085 assert_eq!(
10801086 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 ])
10821095 );
10831096 assert_eq!(
10841097 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 ])
10861106 );
10871107 }
10881108