mirror of
https://github.com/youwen5/iamb.git
synced 2025-08-04 03:28:28 -07:00
Make blockquotes in message visually distict (#466)
This commit is contained in:
parent
963ce3c7c2
commit
331a6bca89
1 changed files with 24 additions and 4 deletions
|
@ -41,6 +41,8 @@ use crate::{
|
|||
util::{join_cell_text, space_text},
|
||||
};
|
||||
|
||||
const QUOTE_COLOR: Color = Color::Indexed(236);
|
||||
|
||||
/// Generate bullet points from a [ListStyle].
|
||||
pub struct BulletIterator {
|
||||
style: ListStyle,
|
||||
|
@ -351,11 +353,14 @@ impl StyleTreeNode {
|
|||
printer.push_span_nobreak(span);
|
||||
},
|
||||
StyleTreeNode::Blockquote(child) => {
|
||||
let mut subp = printer.sub(4);
|
||||
let mut subp = printer.sub(3);
|
||||
child.print(&mut subp, style);
|
||||
|
||||
for mut line in subp.finish() {
|
||||
line.spans.insert(0, Span::styled(" ", style));
|
||||
line.spans
|
||||
.insert(0, Span::styled(line::THICK_VERTICAL, style.fg(QUOTE_COLOR)));
|
||||
line.spans.insert(0, Span::styled(" ", style));
|
||||
printer.push_line(line);
|
||||
}
|
||||
},
|
||||
|
@ -1075,14 +1080,29 @@ pub mod tests {
|
|||
let s = "<blockquote>Hello world!</blockquote>";
|
||||
let tree = parse_matrix_html(s);
|
||||
let text = tree.to_text(10, Style::default(), false, &settings);
|
||||
let style = Style::new().fg(QUOTE_COLOR);
|
||||
assert_eq!(text.lines.len(), 2);
|
||||
assert_eq!(
|
||||
text.lines[0],
|
||||
Line::from(vec![Span::raw(" "), Span::raw("Hello"), Span::raw(" ")])
|
||||
Line::from(vec![
|
||||
Span::raw(" "),
|
||||
Span::styled(line::THICK_VERTICAL, style),
|
||||
Span::raw(" "),
|
||||
Span::raw("Hello"),
|
||||
Span::raw(" "),
|
||||
Span::raw(" "),
|
||||
])
|
||||
);
|
||||
assert_eq!(
|
||||
text.lines[1],
|
||||
Line::from(vec![Span::raw(" "), Span::raw("world"), Span::raw("!")])
|
||||
Line::from(vec![
|
||||
Span::raw(" "),
|
||||
Span::styled(line::THICK_VERTICAL, style),
|
||||
Span::raw(" "),
|
||||
Span::raw("world"),
|
||||
Span::raw("!"),
|
||||
Span::raw(" "),
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue