diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 01b3b5d..443a80e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: run: | ./bootstrap.sh ./configure \ - BUSTED=: LUAROCKS=: MATURIN=: PYTEST=: UV=: GITCLIFF=: NPM=: WASMPACK=:\ + BUSTED=: LUAROCKS=: MATURIN=: PYTEST=: UV=: GITCLIFF=: TYPOS=: NPM=: WASMPACK=:\ --enable-developer-mode \ --without-{bash,fish,zsh}-completion-dir echo "VERSION=$(./build-aux/git-version-gen .tarball-version)" >> $GITHUB_ENV diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 0000000..9c53c27 --- /dev/null +++ b/.typos.toml @@ -0,0 +1,9 @@ +[default] +locale = "en-us" +extend-ignore-identifiers-re = [ + "[bB][aA][zZ]" +] + +[files] +ignore-hidden = false +extend-exclude = ["/.git"] diff --git a/CHANGELOG.md b/CHANGELOG.md index 05a853a..d72010f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [0.5.8] - 2024-07-22 + +### Bug Fixes + +- Make sure TR/AZ reserved words are lower-cased with locale +- Allow freestanding TR question suffixes as reserved without catching unrelated words + ## [0.5.7] - 2024-07-15 ### Bug Fixes diff --git a/Cargo.lock b/Cargo.lock index 1f96d9b..1606c48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -273,7 +273,7 @@ dependencies = [ [[package]] name = "decasify" -version = "0.5.7" +version = "0.5.8" dependencies = [ "assert_cmd", "clap", diff --git a/Cargo.toml b/Cargo.toml index a10112f..ae65a9b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "decasify" -version = "0.5.7" +version = "0.5.8" authors = ["Caleb Maclennan "] edition = "2021" rust-version = "1.73.0" @@ -99,9 +99,13 @@ assert_cmd = "2.0" predicates = "3.1" [package.metadata.git-cliff.git] +protect_breaking_commits = true commit_parsers = [ { message = "^feat", group = "Features" }, { message = "^fix", group = "Bug Fixes" }, { message = "^perf", group = "Performance" }, { message = ".*", skip = true }, ] +commit_preprocessors = [ + { pattern = '.*', replace_command = 'typos --write-changes -' }, +] diff --git a/Makefile.am b/Makefile.am index d3d4de3..b5bd7ca 100644 --- a/Makefile.am +++ b/Makefile.am @@ -58,7 +58,7 @@ release-preview: $(GITCLIFF) --unreleased CHANGELOG.md: .version - $(GITCLIFF) -o $@ + $(GITCLIFF) -o $@ -t $(TAG) decasify-%.md: CHANGELOG.md $(SED) -e '/\.\.\.v$*/,/\.\.\.v/!d' $< | \ diff --git a/README.md b/README.md index b1f906f..d2c21c1 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ A CLI utility, Rust crate, Lua Rock, Python module, and JavaScript module to cas This project was born out of frustration with ALL CAPS TITLES in Markdown that no tooling seemed to properly support casting to title-cased strings, particularly coming from Turkish. Many tools can handle casing single words, and some others can handle English strings, but nothing seemed to be out there for full Turkish strings. -The CLI defaults to titlecase and English, but lower, upper, and scentence case options are also available. +The CLI defaults to titlecase and English, but lower, upper, and sentence case options are also available. The Rust, Lua, Python, and JavaScript library APIs have functions specific to each operation. Where possible the APIs currently default to English rules and (for English) the Gruber style rules, but others are available. The Turkish rules follow Turkish Language Institute's [guidelines][tdk]. diff --git a/configure.ac b/configure.ac index 98d2c72..b50c281 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,7 @@ AM_COND_IF([DEVELOPER_MODE], [ QUE_PROGVAR([wasmpack], [wasm-pack]) # Release tooling QUE_PROGVAR([gitcliff], [git-cliff]) + QUE_PROGVAR([typos], [typos]) ]) QUE_RUST_BOILERPLATE diff --git a/rockspecs/decasify-0.5.8-1.rockspec b/rockspecs/decasify-0.5.8-1.rockspec new file mode 100644 index 0000000..14acfc3 --- /dev/null +++ b/rockspecs/decasify-0.5.8-1.rockspec @@ -0,0 +1,34 @@ +rockspec_format = "1.0" +package = "decasify" +version = "0.5.8-1" + +source = { + url = "git+https://github.com/alerque/decasify.git", + dir = "decasify", + tag = "v0.5.8" +} + +description = { + summary = "Lua C module built from the Rust decasify crate to cast strings to title-case according to locale specific style guides including Turkish support", + detailed = [[ + A Lua library exposed as a C module built from the Rust decasify crate. + Provides casing functions for long strings (not just individual words) + supporting the grammatical style guides of various locales including Turkish. + ]], + license = "GPL-3.0-only", + homepage = "https://github.com/alerque/decasify", +} + +dependencies = { + "lua >= 5.1", + -- v2.0 broke support for LuaRocks 3.1 under Lua 5.1, pin to old version until fixed + -- https://github.com/khvzak/luarocks-build-rust-mlua/pull/10 + "luarocks-build-rust-mlua == 0.1.2-1" +} + +build = { + type = "rust-mlua", + modules = { + "decasify" + } +} diff --git a/src/lib.rs b/src/lib.rs index b4c23ca..32d8966 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -109,7 +109,7 @@ fn to_titlecase_tr(words: Vec<&str>, style: Option) -> String { output.push(first.to_titlecase_tr_or_az_lower_rest()); for word in words { match is_reserved_tr(word.to_string()) { - true => output.push(word.to_string().to_lowercase()), + true => output.push(word.to_string().to_lowercase_tr_az()), false => { output.push(word.to_titlecase_tr_or_az_lower_rest()); } @@ -134,7 +134,7 @@ fn is_reserved_tr(word: String) -> bool { r"^([Vv][Ee]|[İi][Ll][Ee]|[Yy][Aa]|[Vv][Ee]|[Yy][Aa][Hh][Uu][Tt]|[Kk][İi]|[Dd][AaEe])$", ) .unwrap(); - let soruek = Regex::new(r"^([Mm][İiIıUuÜü])").unwrap(); + let soruek = Regex::new(r"^([Mm][İiIıUuÜü])([Dd][İiIıUuÜü][Rr]([Ll][AaEe][Rr])?|[Ss][İiIıUuÜü][Nn]|[Yy][İiIıUuÜü][Zz]|[Ss][İiIıUuÜü][Nn][İiIıUuÜü][Zz]|[Ll][AaEe][Rr])?$").unwrap(); let word = word.as_str(); baglac.is_match(word) || soruek.is_match(word) } @@ -273,6 +273,22 @@ mod tests { "Q&A With Steve Jobs: 'That's What Happens in Technology'" ); + titlecase!( + turkish_question, + InputLocale::TR, + None, + "aç mısın", + "Aç mısın" + ); + + titlecase!( + turkish_question_false, + InputLocale::TR, + None, + "dualarımızda minnettarlık", + "Dualarımızda Minnettarlık" + ); + titlecase!( turkish_chars, InputLocale::TR, diff --git a/src/wasm.rs b/src/wasm.rs index e365df0..a86ab7b 100644 --- a/src/wasm.rs +++ b/src/wasm.rs @@ -27,6 +27,6 @@ pub fn uppercase(input: &str, locale: InputLocale) -> Result { } #[wasm_bindgen] -pub fn scentencecase(input: &str, locale: InputLocale) -> Result { - Ok(to_scentencecase(input, locale)) +pub fn sentencecase(input: &str, locale: InputLocale) -> Result { + Ok(to_sentencecase(input, locale)) }