Update dependencies

This commit is contained in:
Jordan Doyle 2023-11-27 20:14:54 +00:00
parent c2678219d8
commit 47552a638a
No known key found for this signature in database
GPG Key ID: 1EA6BAE6F66DC49A
4 changed files with 813 additions and 702 deletions

1475
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@ edition = "2021"
[dependencies]
argh = "0.1"
log = "0.4"
pretty_env_logger = "0.4"
pretty_env_logger = "0.5"
linked-hash-map = "0.5"
once_cell = "1.14"
parking_lot = "0.12"
@ -21,9 +21,9 @@ gpw = "0.1"
actix = "0.13"
actix-web = "4.0"
htmlescape = "0.3"
askama = "0.11"
bat = "0.20"
syntect = "4.6"
askama = "0.12"
bat = "0.24"
syntect = "5.1"
tokio = { version = "1.20", features = ["sync"] }
futures = "0.3"

View File

@ -14,16 +14,20 @@ thread_local!(pub static BAT_ASSETS: HighlightingAssets = HighlightingAssets::fr
pub fn highlight(content: &str, ext: &str) -> Option<String> {
static SS: Lazy<SyntaxSet> = Lazy::new(SyntaxSet::load_defaults_newlines);
BAT_ASSETS.with(|f| {
let ss = f.get_syntax_set().ok().unwrap_or(&SS);
let syntax = ss.find_syntax_by_extension(ext)?;
let mut html_generator =
ClassedHTMLGenerator::new_with_class_style(syntax, ss, ClassStyle::Spaced);
for line in LinesWithEndings(content.trim()) {
html_generator.parse_html_for_line_which_includes_newline(line);
}
Some(html_generator.finalize())
})
BAT_ASSETS
.with(|f| {
let ss = f.get_syntax_set().ok().unwrap_or(&SS);
let Some(syntax) = ss.find_syntax_by_extension(ext) else {
return Ok(None);
};
let mut html_generator =
ClassedHTMLGenerator::new_with_class_style(syntax, ss, ClassStyle::Spaced);
for line in LinesWithEndings(content.trim()) {
html_generator.parse_html_for_line_which_includes_newline(line)?;
}
Ok::<_, syntect::Error>(Some(html_generator.finalize()))
})
.unwrap_or_else(|_| Some(content.to_string()))
}
pub struct LinesWithEndings<'a>(&'a str);

View File

@ -170,10 +170,10 @@ async fn show_paste(
async fn highlight_css() -> HttpResponse {
static CSS: Lazy<Bytes> = Lazy::new(|| {
highlight::BAT_ASSETS.with(|s| {
Bytes::from(css_for_theme_with_class_style(
s.get_theme("OneHalfDark"),
ClassStyle::Spaced,
))
Bytes::from(
css_for_theme_with_class_style(s.get_theme("OneHalfDark"), ClassStyle::Spaced)
.unwrap(),
)
})
});