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] [dependencies]
argh = "0.1" argh = "0.1"
log = "0.4" log = "0.4"
pretty_env_logger = "0.4" pretty_env_logger = "0.5"
linked-hash-map = "0.5" linked-hash-map = "0.5"
once_cell = "1.14" once_cell = "1.14"
parking_lot = "0.12" parking_lot = "0.12"
@ -21,9 +21,9 @@ gpw = "0.1"
actix = "0.13" actix = "0.13"
actix-web = "4.0" actix-web = "4.0"
htmlescape = "0.3" htmlescape = "0.3"
askama = "0.11" askama = "0.12"
bat = "0.20" bat = "0.24"
syntect = "4.6" syntect = "5.1"
tokio = { version = "1.20", features = ["sync"] } tokio = { version = "1.20", features = ["sync"] }
futures = "0.3" 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> { pub fn highlight(content: &str, ext: &str) -> Option<String> {
static SS: Lazy<SyntaxSet> = Lazy::new(SyntaxSet::load_defaults_newlines); static SS: Lazy<SyntaxSet> = Lazy::new(SyntaxSet::load_defaults_newlines);
BAT_ASSETS.with(|f| { BAT_ASSETS
.with(|f| {
let ss = f.get_syntax_set().ok().unwrap_or(&SS); let ss = f.get_syntax_set().ok().unwrap_or(&SS);
let syntax = ss.find_syntax_by_extension(ext)?; let Some(syntax) = ss.find_syntax_by_extension(ext) else {
return Ok(None);
};
let mut html_generator = let mut html_generator =
ClassedHTMLGenerator::new_with_class_style(syntax, ss, ClassStyle::Spaced); ClassedHTMLGenerator::new_with_class_style(syntax, ss, ClassStyle::Spaced);
for line in LinesWithEndings(content.trim()) { for line in LinesWithEndings(content.trim()) {
html_generator.parse_html_for_line_which_includes_newline(line); html_generator.parse_html_for_line_which_includes_newline(line)?;
} }
Some(html_generator.finalize()) Ok::<_, syntect::Error>(Some(html_generator.finalize()))
}) })
.unwrap_or_else(|_| Some(content.to_string()))
} }
pub struct LinesWithEndings<'a>(&'a str); pub struct LinesWithEndings<'a>(&'a str);

View file

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