File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
app/src/components/markdown_renderer Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -44,10 +44,24 @@ pub fn code_block(props: &CodeBlockProps) -> Html {
4444 } ) ;
4545 }
4646
47+ let total_lines = if let Some ( lines) = & * highlighted_lines {
48+ lines. len ( )
49+ } else {
50+ props. code . as_ref ( ) . split_inclusive ( '\n' ) . count ( )
51+ } ;
52+ let max_digits = total_lines. max ( 1 ) . to_string ( ) . len ( ) ;
53+ let line_number_style = format ! ( "min-width: {}ch;" , max_digits + 1 ) ;
54+
4755 let render_line = |index : usize , content : Html | {
4856 html ! {
4957 <span class="grid grid-cols-[auto,1fr] gap-4" >
50- <span class="w-12 select-none text-right pr-2 text-slate-500 tabular-nums" aria-hidden="true" >{ index + 1 } </span>
58+ <span
59+ class="sticky left-0 z-10 block select-none bg-black/60 backdrop-blur-md text-right pr-2 text-slate-500 tabular-nums"
60+ style={ line_number_style. clone( ) }
61+ aria-hidden="true"
62+ >
63+ { index + 1 }
64+ </span>
5165 <span class="block whitespace-pre" >
5266 { content }
5367 </span>
You can’t perform that action at this time.
0 commit comments