Skip to content

Commit

Permalink
Fixes before release.
Browse files Browse the repository at this point in the history
  • Loading branch information
finnbear committed Sep 24, 2024
1 parent 6c4b4f9 commit bd299ce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions pages/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use web_sys::{HtmlInputElement, window, InputEvent, HtmlTextAreaElement, wasm_bindgen::JsCast};
use yew::{html, Html, Callback, function_component, TargetCast};
use rustrict::{Censor, censor_and_analyze_pii};
use rustrict::{censor_and_analyze_pii, Censor, WordBreak};

#[function_component(App)]
fn app() -> Html {
Expand All @@ -18,8 +18,9 @@ fn app() -> Html {
let (censored, analysis) = censor.censor_and_analyze();
let count = censor.total_matches();
let detections = censor.detections();
let width = rustrict::width_str(&uncensored);
let result = format!("{analysis:?} (width={width}, count={count}, detections={detections:?}, pii={pii:?})");
let width = rustrict::width_str(&uncensored);
let max_unbroken = rustrict::width_str_max_unbroken(&uncensored, WordBreak::BreakAll);
let result = format!("{analysis:?} (width={width}, max-unbroken={max_unbroken}, count={count}, detections={detections:?}, pii={pii:?})");
analysis_element.set_inner_html(&result);
censored_element.set_value(&censored);
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub use replacements::Replacements;
pub use trie::Trie;

#[cfg(feature = "width")]
pub use width::{trim_to_width, width, width_str, width_str_max_unbroken};
pub use width::{trim_to_width, width, width_str, width_str_max_unbroken, WordBreak};

#[cfg(feature = "censor")]
pub use typ::Type;
Expand Down
1 change: 1 addition & 0 deletions src/width.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub fn width_str(s: &str) -> usize {
#[non_exhaustive]
pub enum WordBreak {
// TODO: BreakWord
/// Same as CSS's `word-break: break-all;`.
BreakAll,
}

Expand Down

0 comments on commit bd299ce

Please sign in to comment.