mirror of
https://github.com/getzola/zola
synced 2024-12-12 05:12:29 +00:00
Update syntect
This commit is contained in:
parent
bdbe73e23e
commit
ee8de20a6e
6 changed files with 251 additions and 342 deletions
577
Cargo.lock
generated
577
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -97,7 +97,7 @@ impl Markdown {
|
|||
|
||||
pub fn export_theme_css(&self, theme_name: &str) -> String {
|
||||
let theme = self.get_highlight_theme_by_name(theme_name);
|
||||
css_for_theme_with_class_style(theme, CLASS_STYLE)
|
||||
css_for_theme_with_class_style(theme, CLASS_STYLE).expect("the function can't even error?")
|
||||
}
|
||||
|
||||
pub fn init_extra_syntaxes_and_highlight_themes(&mut self, path: &Path) -> Result<()> {
|
||||
|
|
|
@ -32,7 +32,7 @@ serde_yaml = "0.8"
|
|||
sha2 = "0.10"
|
||||
slug = "0.1"
|
||||
svg_metadata = "0.4"
|
||||
syntect = "4"
|
||||
syntect = "5"
|
||||
tera = { version = "1", features = ["preserve_order"] }
|
||||
time = "0.3"
|
||||
toml = "0.5"
|
||||
|
|
|
@ -37,13 +37,15 @@ impl<'config> ClassHighlighter<'config> {
|
|||
/// also use of the `load_defaults_newlines` version of the syntaxes.
|
||||
pub fn highlight_line(&mut self, line: &str) -> String {
|
||||
debug_assert!(line.ends_with('\n'));
|
||||
let parsed_line = self.parse_state.parse_line(line, self.syntax_set);
|
||||
let parsed_line =
|
||||
self.parse_state.parse_line(line, self.syntax_set).expect("failed to parse line");
|
||||
let (formatted_line, delta) = line_tokens_to_classed_spans(
|
||||
line,
|
||||
parsed_line.as_slice(),
|
||||
CLASS_STYLE,
|
||||
&mut self.scope_stack,
|
||||
);
|
||||
)
|
||||
.expect("line_tokens_to_classed_spans should not fail");
|
||||
self.open_spans += delta;
|
||||
formatted_line
|
||||
}
|
||||
|
@ -81,12 +83,14 @@ impl<'config> InlineHighlighter<'config> {
|
|||
}
|
||||
|
||||
pub fn highlight_line(&mut self, line: &str) -> String {
|
||||
let regions = self.h.highlight(line, self.syntax_set);
|
||||
let regions =
|
||||
self.h.highlight_line(line, self.syntax_set).expect("failed to highlight line");
|
||||
// TODO: add a param like `IncludeBackground` for `IncludeForeground` in syntect
|
||||
let highlighted = styled_line_to_highlighted_html(
|
||||
®ions,
|
||||
IncludeBackground::IfDifferent(self.bg_color),
|
||||
);
|
||||
)
|
||||
.expect("styled_line_to_highlighted_html should not error");
|
||||
// Spans don't get nested even if the scopes generated by the syntax highlighting do,
|
||||
// so this is safe even when some internal scope happens to have the same color
|
||||
// as the default foreground color. Also note that `"`s in the original source
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue