Terminal Markdown previewer — GUI-like experience.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #31 from RivoLink/fix/heading-inline-code

fix: heading inline code

authored by

Rivo Link and committed by
GitHub
d9b03aa5 b341011b

+20 -8
+20 -8
src/markdown/mod.rs
··· 349 349 3 => theme.heading_3, 350 350 _ => theme.heading_other, 351 351 }; 352 - let style = Style::default().fg(color).add_modifier(match level { 352 + let heading_style = Style::default().fg(color).add_modifier(match level { 353 353 1..=3 => Modifier::BOLD, 354 354 _ => Modifier::empty(), 355 355 }); 356 356 let title: String = spans.iter().map(|s| s.content.as_ref()).collect(); 357 - let rendered_title = if level == 3 { 358 - format!("{title} ") 359 - } else { 360 - title.clone() 361 - }; 362 357 toc.push(TocEntry { 363 358 level, 364 359 title: title.clone(), 365 360 line: lines.len(), 366 361 }); 367 - spans.clear(); 368 - lines.push(Line::from(vec![Span::styled(rendered_title, style)])); 362 + let styled_spans: Vec<Span<'static>> = spans 363 + .drain(..) 364 + .map(|span| { 365 + let mut style = heading_style; 366 + if span.style.bg.is_some() { 367 + style.fg = span.style.fg; 368 + style.bg = span.style.bg; 369 + style.sub_modifier = Modifier::BOLD; 370 + } 371 + Span::styled(span.content, style) 372 + }) 373 + .collect(); 374 + if level == 3 { 375 + let mut s = styled_spans; 376 + s.push(Span::styled(" ", heading_style)); 377 + lines.push(Line::from(s)); 378 + } else { 379 + lines.push(Line::from(styled_spans)); 380 + }; 369 381 370 382 match level { 371 383 1 => lines.push(Line::from(Span::styled(