Fix first line background.
Added a comment if the background in desired in the future.
This commit is contained in:
@@ -10,9 +10,7 @@ use std::fs;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use syntect::easy::HighlightLines;
|
use syntect::easy::HighlightLines;
|
||||||
use syntect::highlighting::ThemeSet;
|
use syntect::highlighting::ThemeSet;
|
||||||
use syntect::html::{
|
use syntect::html::{IncludeBackground, append_highlighted_html_for_styled_line};
|
||||||
IncludeBackground, append_highlighted_html_for_styled_line, start_highlighted_html_snippet,
|
|
||||||
};
|
|
||||||
use syntect::parsing::SyntaxSet;
|
use syntect::parsing::SyntaxSet;
|
||||||
use syntect::util::LinesWithEndings;
|
use syntect::util::LinesWithEndings;
|
||||||
|
|
||||||
@@ -99,7 +97,8 @@ impl qobject::FileSystem {
|
|||||||
)
|
)
|
||||||
.unwrap_or_else(|| ss.find_syntax_plain_text());
|
.unwrap_or_else(|| ss.find_syntax_plain_text());
|
||||||
let mut highlighter = HighlightLines::new(lang, theme);
|
let mut highlighter = HighlightLines::new(lang, theme);
|
||||||
let (mut output, _bg) = start_highlighted_html_snippet(theme);
|
// If you care about the background, see `start_highlighted_html_snippet(theme);`.
|
||||||
|
let mut output = String::from("<pre>\n");
|
||||||
for line in LinesWithEndings::from(lines.as_str()) {
|
for line in LinesWithEndings::from(lines.as_str()) {
|
||||||
let regions = highlighter
|
let regions = highlighter
|
||||||
.highlight_line(line, &ss)
|
.highlight_line(line, &ss)
|
||||||
|
|||||||
Reference in New Issue
Block a user