Skip to content

Commit 91a452f

Browse files
committed
refactor: simplify
1 parent 2d745ae commit 91a452f

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

src/usage_md.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,24 +205,20 @@ fn get_help_text(arg: &Arg) -> Cow<'static, str> {
205205
}
206206

207207
fn render_examples_section<'a>(lines: impl Iterator<Item = &'a str>, out: &mut String) {
208-
let mut current_title: Option<&'a str> = None;
209208
for line in lines {
210209
let line = line.trim();
211210

212211
if line.is_empty() {
213212
continue;
214213
}
215214

216-
if let Some(cmd) = line.strip_prefix('$').map(str::trim) {
217-
let heading = if let Some(title) = current_title.take() {
218-
title.to_string()
219-
} else {
220-
format!("`{cmd}`")
221-
};
222-
out.push_str(&format!("### {heading}\n\n```sh\n{cmd}\n```\n\n"));
223-
} else {
224-
current_title = Some(line);
215+
if let Some(command) = line.strip_prefix('$') {
216+
let command = command.trim();
217+
out.push_str(&format!("```sh\n{command}\n```\n\n"));
218+
continue;
225219
}
220+
221+
out.push_str(&format!("### {line}\n\n"));
226222
}
227223
}
228224

0 commit comments

Comments
 (0)