summaryrefslogtreecommitdiff
path: root/src/renderer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer.rs')
-rw-r--r--src/renderer.rs31
1 files changed, 5 insertions, 26 deletions
diff --git a/src/renderer.rs b/src/renderer.rs
index ad5201f..f492f1e 100644
--- a/src/renderer.rs
+++ b/src/renderer.rs
@@ -4,7 +4,11 @@ use std::{
path::Path,
};
-use crate::{logger::Logger, normalizer::NormalizedPath, util::path_display::display_path};
+use crate::{
+ logger::Logger,
+ normalizer::NormalizedPath,
+ util::{language::detect_language, path_display::display_path},
+};
const DEFAULT_MAX_FILE_SIZE: u64 = 1_000_000;
@@ -142,31 +146,6 @@ fn human_readable_size(bytes: u64) -> String {
}
}
-fn detect_language(filename: &Path, contents: &str) -> &'static str {
- let ext = filename
- .extension()
- .and_then(|e| e.to_str())
- .map(|e| e.to_ascii_lowercase());
- let ext_str = ext.as_deref();
- match ext_str {
- Some("rs") => "rust",
- Some("py") => "python",
- Some("json") => "json",
- _ => {
- if let Some(first_line) = contents.lines().next() {
- if first_line.contains("python")
- {
- return "python";
- }
- if first_line.contains("bash") {
- return "bash";
- }
- }
- ""
- }
- }
-}
-
#[cfg(test)]
mod tests {
use std::{