1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! Core formatting engine.
//!
//! This module provides whole-text formatting.
//!
//! # Examples
//!
//! ```rust
//! use evfmt::{FormatResult, Policy, format_text};
//!
//! let policy = Policy::default();
//!
//! assert_eq!(
//! format_text("#\u{FE0E}", &policy),
//! FormatResult::Changed("#".into())
//! );
//! assert_eq!(format_text("#", &policy), FormatResult::Unchanged);
//! ```
//
// formatter.rs — The core formatting engine.
//
// Uses the sequence-aware scanner to process text, then asks findings analysis
// for each policy-aware finding and applies the default replacement decision.
//
// AUDIT NOTE — Key properties maintained by this module:
//
// 1. IDEMPOTENCY: format(format(x)) == format(x). Verified by prop_idempotent.
// 2. LOSSLESSNESS: only FE0E/FE0F are inserted/removed; all other content is
// preserved. Verified by prop_only_modifies_selectors.
// 3. NO VIOLATIONS: re-scanning the output produces zero violations under
// the same policy. Verified by prop_no_violations_in_output.
// 4. CURRENT IMPLEMENTATION SHAPE: format_text scans the input once, analyzes
// each item, and applies the default replacement decision. This is this
// module's chosen boundary, not a spec requirement; output canonicality is
// verified by prop_no_violations_in_output.
use cratefindings;
use cratePolicy;
use cratescanner;
/// The result of formatting a text string.
///
/// # Examples
///
/// ```rust
/// use evfmt::{FormatResult, Policy, format_text};
///
/// match format_text("#\u{FE0E}", &Policy::default()) {
/// FormatResult::Changed(text) => assert_eq!(text, "#"),
/// FormatResult::Unchanged => panic!("the selector should be removed"),
/// }
/// ```
/// Format the input text according to the given policy.
///
/// # Examples
///
/// ```rust
/// use evfmt::{FormatResult, Policy, format_text};
///
/// let policy = Policy::default();
///
/// assert_eq!(
/// format_text("#\u{FE0E}", &policy),
/// FormatResult::Changed("#".to_owned())
/// );
/// assert_eq!(
/// format_text("plain text", &policy),
/// FormatResult::Unchanged
/// );
/// ```