Skip to content

Commit c52cd1a

Browse files
committed
[Release] v0.12.0
1 parent 7865657 commit c52cd1a

File tree

7 files changed

+20
-15
lines changed

7 files changed

+20
-15
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resolver = "2"
33
members = ["cli", "core", "wasm", "xtask"]
44

55
[workspace.package]
6-
version = "0.11.7"
6+
version = "0.12.0"
77
edition = "2021"
88
authors = ["mist.zzh@gmail.com"]
99

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ path = "src/main.rs"
1515
ansi_term = "0.12.1"
1616
anyhow = "1.0.91"
1717
clap = { version = "4.5.21", features = ["derive"] }
18-
codesnap = { path = "../core", version = "0.11.5", features = ["full"] }
18+
codesnap = { path = "../core", version = "0.12.0", features = ["full"] }
1919
ferris-says = "0.3.2"
2020
home = "0.5.9"
2121
indicatif = "0.17.9"

core/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ schemars = "0.8.22"
3333
reqwest = "0.12.15"
3434
mime_guess = "2.0.5"
3535
url = "2.5.4"
36-
hyperpolyglot = { git = "https://github.com/codesnap-rs/hyperpolyglot", branch = "master" }
36+
hyperpolyglot = { git = "https://github.com/codesnap-rs/hyperpolyglot", branch = "master", version = "0.1.7", optional = true }
3737

3838
[features]
3939
default = []
4040
copy = ["arboard"]
41-
full = ["copy"]
41+
auto-detect = ["hyperpolyglot"]
42+
full = ["copy", "auto-detect"]
4243

4344
[[example]]
4445
name = "basic"

core/src/utils/syntax_provider.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[cfg(feature = "auto-detect")]
12
use hyperpolyglot::detectors::classify;
23
use syntect::parsing::{SyntaxReference, SyntaxSet};
34

@@ -23,12 +24,15 @@ impl SyntaxProvider {
2324
.map_err(|_| RenderError::NoSuchFile(file_path.clone()))?,
2425
None => self.syntax_set.find_syntax_by_first_line(code),
2526
},
26-
}
27-
.or_else(|| {
27+
};
28+
29+
#[cfg(feature = "auto-detect")]
30+
let syntax = syntax.or_else(|| {
2831
self.syntax_set
2932
.find_syntax_by_token(classify(code, &*vec![]))
30-
})
31-
.unwrap_or_else(|| self.syntax_set.find_syntax_plain_text());
33+
});
34+
35+
let syntax = syntax.unwrap_or_else(|| self.syntax_set.find_syntax_plain_text());
3236

3337
Ok(syntax.to_owned())
3438
}

wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ repository = "https://github.com/mistricky/CodeSnap"
1111
crate-type = ["cdylib"]
1212

1313
[dependencies]
14-
codesnap = { version = "0.11.5", path = "../core" }
14+
codesnap = { version = "0.12.0", path = "../core" }
1515
console_error_panic_hook = "0.1.7"
1616
wasm-bindgen = "0.2.100"

xtask/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
22
name = "xtask"
3-
version = "0.1.0"
3+
version = "0.12.0"
44
edition = "2021"
55

66
[dependencies]
77
schemars = "0.8.22"
88
serde_json = "1.0.140"
9-
codesnap = { path = "../core", version = "0.11.5" }
9+
codesnap = { path = "../core", version = "0.12.0" }
1010
clap = { version = "4.5.21", features = ["derive"] }
1111

0 commit comments

Comments
 (0)