summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2026-06-08 04:05:14 +0300
committerA Farzat <a@farzat.xyz>2026-06-08 04:05:14 +0300
commit091ae954417b7895062691e3713ebf406c986f29 (patch)
treee5f5c16b7568f0f1ed4bdbc5e10e564699ea9cd4 /src/util
parenta088bbbbd0eed36b9b4eb3d39dc9bc306d33f185 (diff)
downloadrepo2markdown-091ae954417b7895062691e3713ebf406c986f29.tar.gz
repo2markdown-091ae954417b7895062691e3713ebf406c986f29.zip
Support YAML, JS, and TOML
Diffstat (limited to 'src/util')
-rw-r--r--src/util/language.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/util/language.rs b/src/util/language.rs
index f0870c8..080b26e 100644
--- a/src/util/language.rs
+++ b/src/util/language.rs
@@ -16,6 +16,9 @@ fn detect_from_extension(filename: &Path) -> Option<&'static str> {
Some("rs") => Some("rust"),
Some("py") => Some("python"),
Some("json") => Some("json"),
+ Some("toml") => Some("toml"),
+ Some("yaml") | Some("yml") => Some("yaml"),
+ Some("js") | Some("jsx") => Some("javascript"),
_ => None,
}
}
@@ -69,4 +72,29 @@ mod tests {
let contents = "#!/bin/bash\nprint('hello')";
assert_eq!(detect_language(Path::new("main.py"), contents), "python");
}
+
+ #[test]
+ fn yaml_extension_is_detected() {
+ assert_eq!(detect_language(Path::new("config.yaml"), ""), "yaml");
+ }
+
+ #[test]
+ fn yml_alias_maps_to_yaml() {
+ assert_eq!(detect_language(Path::new("config.yml"), ""), "yaml");
+ }
+
+ #[test]
+ fn js_extension_is_detected() {
+ assert_eq!(detect_language(Path::new("file.js"), ""), "javascript");
+ }
+
+ #[test]
+ fn jsx_maps_to_javascript() {
+ assert_eq!(detect_language(Path::new("file.jsx"), ""), "javascript");
+ }
+
+ #[test]
+ fn toml_extension_is_detected() {
+ assert_eq!(detect_language(Path::new("Cargo.toml"), ""), "toml");
+ }
}