Browse Source

Change highlighting to not include duplicated background colors

index-subcmd
C Jones 6 years ago
parent
commit
dabc614fb3
1 changed files with 8 additions and 2 deletions
  1. +8
    -2
      components/rendering/src/markdown.rs

+ 8
- 2
components/rendering/src/markdown.rs View File

@@ -51,6 +51,7 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result<Render
// Set while parsing
let mut error = None;

let mut background = IncludeBackground::Yes;
let mut highlighter: Option<HighlightLines> = None;
// If we get text in header, we need to insert the id and a anchor
let mut in_header = false;
@@ -93,7 +94,7 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result<Render
// if we are in the middle of a code block
if let Some(ref mut highlighter) = highlighter {
let highlighted = &highlighter.highlight(&text);
let html = styles_to_coloured_html(highlighted, IncludeBackground::Yes);
let html = styles_to_coloured_html(highlighted, background);
return Event::Html(Owned(html));
}

@@ -107,7 +108,12 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result<Render

let theme = &THEME_SET.themes[&context.config.highlight_theme];
match get_highlighter(&theme, info, context.base_path, &context.config.extra_syntaxes) {
Ok(h) => highlighter = Some(h),
Ok(h) => {
highlighter = Some(h);
// This selects the background color the same way that start_coloured_html_snippet does
let color = theme.settings.background.unwrap_or(::syntect::highlighting::Color::WHITE);
background = IncludeBackground::IfDifferent(color);
}
Err(err) => {
error = Some(format!("Could not load syntax: {}", err).into());
return Event::Html(Borrowed(""));


Loading…
Cancel
Save