diff --git a/libs/braillify/src/fraction.rs b/libs/braillify/src/fraction.rs index a6d71cd..78b8514 100644 --- a/libs/braillify/src/fraction.rs +++ b/libs/braillify/src/fraction.rs @@ -94,12 +94,9 @@ fn read_braced_content(iter: &mut std::iter::Peekable) -> Optio iter.next(); } _ => { - if let Some(digit) = normalize_digit(*c) { - content.push(digit); - iter.next(); - } else { - return None; - } + let digit = normalize_digit(*c)?; + content.push(digit); + iter.next(); } } } diff --git a/libs/braillify/src/rules/english_ueb/engine.rs b/libs/braillify/src/rules/english_ueb/engine.rs index d8a700c..809e833 100644 --- a/libs/braillify/src/rules/english_ueb/engine.rs +++ b/libs/braillify/src/rules/english_ueb/engine.rs @@ -4244,10 +4244,9 @@ fn push_spatial_char(out: &mut Vec, c: char) -> Option<()> { out.extend([CAPITAL, decode_unicode('⠜')]); } else if c == '<' { out.extend([CAPITAL, decode_unicode('⠣')]); - } else if let Some(cells) = super::rule_16::spatial_symbol(c) { - out.extend(cells); } else { - return None; + let cells = super::rule_16::spatial_symbol(c)?; + out.extend(cells); } Some(()) } diff --git a/libs/braillify/src/rules/english_ueb/rule_11.rs b/libs/braillify/src/rules/english_ueb/rule_11.rs index 74bead5..df1df47 100644 --- a/libs/braillify/src/rules/english_ueb/rule_11.rs +++ b/libs/braillify/src/rules/english_ueb/rule_11.rs @@ -330,7 +330,7 @@ fn encode_expr_with_options( let (next, item) = if chars.get(i) == Some(&'{') { take_braced(chars, i)? } else { - (i + 1, &chars[i..i + 1]) + (i + 1, chars.get(i..i + 1)?) }; let need_grouping = item_needs_braille_grouping(item); if need_grouping { @@ -736,6 +736,13 @@ mod tests { assert_eq!(encode_technical(&"@".chars().collect::>()), None); } + #[rstest::rstest] + #[case::dangling_superscript('^')] + #[case::dangling_subscript('_')] + fn rejects_dangling_script_marker_without_panicking(#[case] marker: char) { + assert_eq!(encode_technical(&[marker]), None); + } + #[test] fn helper_primitives_reject_invalid_inputs() { let mut out = Vec::new(); diff --git a/package.json b/package.json index 01704bf..02c8b4e 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,10 @@ "scripts": { "lint": "oxlint . && cargo fmt --all -- --check && cargo clippy --workspace --all-targets -- -D warnings", "lint:fix": "oxlint . --fix && cargo fmt --all && cargo clippy --workspace --all-targets --fix --allow-dirty --allow-staged -- -D warnings && cargo clippy --workspace --all-targets -- -D warnings", - "test": "cargo tarpaulin --engine llvm --out xml --out stdout -- --skip test_by_testcase && bun test --coverage && cd py-test && uv run pytest", + "test": "bun run test:rust && bun run test:node && bun run test:python", + "test:rust": "cargo tarpaulin --engine llvm --out xml --out stdout -- --skip test_by_testcase", + "test:node": "bun test --coverage", + "test:python": "cd py-test && uv run --locked pytest", "test:testcase": "cargo test -p braillify test_by_testcase -- --nocapture", "preinstall": "uv sync && (cargo install wasm-pack || node -e \"process.exit(0)\") && (pip install maturin || \"process.exit(0)\")", "build": "cargo build --release -p braillify && bun -F braillify build && cd packages/python && maturin build --release --out dist", diff --git a/py-test/pyproject.toml b/py-test/pyproject.toml index 25816da..9d003b4 100644 --- a/py-test/pyproject.toml +++ b/py-test/pyproject.toml @@ -4,7 +4,7 @@ version = "0.1.0" description = "" authors = [{ name = "owjs3901", email = "owjs3901@gmail.com" }] readme = "README.md" -requires-python = ">=3.13" +requires-python = ">=3.11" dependencies = ["braillify"] [tool.uv.sources] diff --git a/pyproject.toml b/pyproject.toml index af6934b..7328d22 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ version = "0.1.0" description = "" authors = [{ name = "owjs3901", email = "owjs3901@gmail.com" }] readme = "README.md" -requires-python = ">=3.13" +requires-python = ">=3.11" [tool.uv.workspace] members = ["packages/python", "py-test"] diff --git a/uv.lock b/uv.lock index 2ba0b4a..447865b 100644 --- a/uv.lock +++ b/uv.lock @@ -1,6 +1,6 @@ version = 1 revision = 3 -requires-python = ">=3.13" +requires-python = ">=3.11" [manifest] members = [