Skip to content

Commit

Permalink
Merge tag 'v0.5.8' into relicence
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jul 23, 2024
2 parents 34cbab2 + e24efd3 commit f09fabb
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[default]
locale = "en-us"
extend-ignore-identifiers-re = [
"[bB][aA][zZ]"
]

[files]
ignore-hidden = false
extend-exclude = ["/.git"]
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "decasify"
version = "0.5.7"
version = "0.5.8"
authors = ["Caleb Maclennan <[email protected]>"]
edition = "2021"
rust-version = "1.73.0"
Expand Down Expand Up @@ -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 = "<!-- 0 -->Features" },
{ message = "^fix", group = "<!-- 1 -->Bug Fixes" },
{ message = "^perf", group = "<!-- 2 -->Performance" },
{ message = ".*", skip = true },
]
commit_preprocessors = [
{ pattern = '.*', replace_command = 'typos --write-changes -' },
]
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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' $< | \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions rockspecs/decasify-0.5.8-1.rockspec
Original file line number Diff line number Diff line change
@@ -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"
}
}
20 changes: 18 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn to_titlecase_tr(words: Vec<&str>, style: Option<StyleGuide>) -> 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());
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ pub fn uppercase(input: &str, locale: InputLocale) -> Result<String, JsError> {
}

#[wasm_bindgen]
pub fn scentencecase(input: &str, locale: InputLocale) -> Result<String, JsError> {
Ok(to_scentencecase(input, locale))
pub fn sentencecase(input: &str, locale: InputLocale) -> Result<String, JsError> {
Ok(to_sentencecase(input, locale))
}

0 comments on commit f09fabb

Please sign in to comment.