diff --git a/components/rendering/src/codeblock/mod.rs b/components/rendering/src/codeblock/mod.rs
index 4864db2b89..1e8d1eb09b 100644
--- a/components/rendering/src/codeblock/mod.rs
+++ b/components/rendering/src/codeblock/mod.rs
@@ -136,41 +136,32 @@ impl<'config> CodeBlock<'config> {
}
}
- if self.line_numbers {
- buffer.push_str("
");
- let num = format!("{}", self.line_number_start + i);
+ let maybe_mark = |buffer: &mut String, s: &str| {
if is_higlighted {
buffer.push_str("");
} else {
buffer.push('>')
}
- buffer.push_str(&num);
+ buffer.push_str(s);
buffer.push_str("");
} else {
- buffer.push_str(&num);
+ buffer.push_str(s);
}
+ };
+
+ if self.line_numbers {
+ buffer.push_str(" |
");
+ let num = format!("{}", self.line_number_start + i);
+ maybe_mark(&mut buffer, &num);
buffer.push_str(" | ");
}
let highlighted_line = self.highlighter.highlight_line(line);
- if is_higlighted {
- buffer.push_str("");
- } else {
- buffer.push('>')
- }
- buffer.push_str(&highlighted_line);
- buffer.push_str("");
- } else {
- buffer.push_str(&highlighted_line);
- }
+ maybe_mark(&mut buffer, &highlighted_line);
}
if let Some(rest) = self.highlighter.finalize() {
|