ci: add GitHub Actions workflows with semantic-release auto-versioning
chore: fix all 702 clippy warnings across codebase - auto-fix 475 via cargo clippy --fix - fix remaining 227 manually: uninlined_format_args, redundant_closure, match_same_arms, underscore_binding, format_push_string, items_after_statements, needless_pass_by_value, clone_on_copy, case_sensitive_extension, single_match/let-else, write_with_newline, and other clippy lints
This commit is contained in:
+11
-25
@@ -14,12 +14,13 @@ use super::theme::Theme;
|
||||
|
||||
/// Render a markdown string into styled terminal spans, word-wrapped to `width`.
|
||||
///
|
||||
/// Flow: pulldown_cmark parses `text` into an event stream → each
|
||||
/// Flow: `pulldown_cmark` parses `text` into an event stream → each
|
||||
/// Start/End/Text/Code/Break event is translated into styled `Span`s →
|
||||
/// if `width > 0`, a second pass wraps long lines.
|
||||
///
|
||||
/// Return: a flat vec of styled spans; `chat::split_spans_into_lines`
|
||||
/// turns it back into `Line`s for the Paragraph widget.
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub fn render_markdown(text: &str, width: u16) -> Vec<Span<'static>> {
|
||||
let mut spans = Vec::new();
|
||||
let parser = pulldown_cmark::Parser::new(text);
|
||||
@@ -61,9 +62,6 @@ pub fn render_markdown(text: &str, width: u16) -> Vec<Span<'static>> {
|
||||
pulldown_cmark::Tag::Paragraph => {
|
||||
first_in_paragraph = true;
|
||||
}
|
||||
pulldown_cmark::Tag::Emphasis => {}
|
||||
pulldown_cmark::Tag::Strong => {}
|
||||
pulldown_cmark::Tag::List(_) => {}
|
||||
pulldown_cmark::Tag::Item => {
|
||||
// List item bullet
|
||||
spans.push(Span::styled(
|
||||
@@ -79,7 +77,7 @@ pub fn render_markdown(text: &str, width: u16) -> Vec<Span<'static>> {
|
||||
// We push the URL as a tooltip-like suffix
|
||||
// After the link text ends, we'll add the URL
|
||||
spans.push(Span::styled(
|
||||
format!("]({})", dest_url),
|
||||
format!("]({dest_url})"),
|
||||
Style::default().fg(Theme::TEXT_MUTED).add_modifier(Modifier::ITALIC),
|
||||
));
|
||||
}
|
||||
@@ -111,14 +109,7 @@ pub fn render_markdown(text: &str, width: u16) -> Vec<Span<'static>> {
|
||||
first_in_paragraph = true;
|
||||
spans.push(Span::raw("\n\n"));
|
||||
}
|
||||
pulldown_cmark::TagEnd::Emphasis => {}
|
||||
pulldown_cmark::TagEnd::Strong => {}
|
||||
pulldown_cmark::TagEnd::List(_) => {}
|
||||
pulldown_cmark::TagEnd::Item => {
|
||||
spans.push(Span::raw("\n"));
|
||||
}
|
||||
pulldown_cmark::TagEnd::Link => {}
|
||||
pulldown_cmark::TagEnd::BlockQuote(_) => {
|
||||
pulldown_cmark::TagEnd::Item | pulldown_cmark::TagEnd::BlockQuote(_) => {
|
||||
spans.push(Span::raw("\n"));
|
||||
}
|
||||
_ => {}
|
||||
@@ -128,7 +119,7 @@ pub fn render_markdown(text: &str, width: u16) -> Vec<Span<'static>> {
|
||||
let s = text.to_string();
|
||||
if in_code_block {
|
||||
spans.push(Span::styled(
|
||||
format!(" {}", s),
|
||||
format!(" {s}"),
|
||||
Style::default().fg(Theme::ACCENT_TEAL).bg(Theme::CODE_BG),
|
||||
));
|
||||
} else if in_heading {
|
||||
@@ -138,14 +129,9 @@ pub fn render_markdown(text: &str, width: u16) -> Vec<Span<'static>> {
|
||||
3 => Theme::ACCENT_PURPLE,
|
||||
_ => Theme::TEXT,
|
||||
};
|
||||
let prefix = match heading_level {
|
||||
1 => " ",
|
||||
2 => " ",
|
||||
3 => " ",
|
||||
_ => " ",
|
||||
};
|
||||
let prefix = " ";
|
||||
spans.push(Span::styled(
|
||||
format!("{}{}", prefix, s),
|
||||
format!("{prefix}{s}"),
|
||||
Style::default().fg(color).add_modifier(Modifier::BOLD),
|
||||
));
|
||||
} else {
|
||||
@@ -160,7 +146,7 @@ pub fn render_markdown(text: &str, width: u16) -> Vec<Span<'static>> {
|
||||
pulldown_cmark::Event::Code(text) => {
|
||||
// Inline code with background
|
||||
spans.push(Span::styled(
|
||||
format!(" {} ", text),
|
||||
format!(" {text} "),
|
||||
Style::default()
|
||||
.fg(Theme::ACCENT_TEAL)
|
||||
.bg(Theme::CODE_BAR)
|
||||
@@ -195,10 +181,10 @@ pub fn render_markdown(text: &str, width: u16) -> Vec<Span<'static>> {
|
||||
|
||||
spans_out.push(Span::styled(text_str.to_string(), style));
|
||||
|
||||
if !text_str.contains('\n') {
|
||||
line_len += remaining;
|
||||
} else {
|
||||
if text_str.contains('\n') {
|
||||
line_len = text_str.split('\n').next_back().unwrap_or("").len();
|
||||
} else {
|
||||
line_len += remaining;
|
||||
}
|
||||
}
|
||||
spans = spans_out;
|
||||
|
||||
Reference in New Issue
Block a user