Skip to content

Commit f1d855b

Browse files
committed
Add new changes as an example to the README
1 parent 9e94f4c commit f1d855b

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,45 @@ void func3(){}
122122
println!("diff_lines:");
123123
println!("{}", diff_lines(code1_a, code1_b));
124124
```
125+
#### Diff Lines with Custom Config
126+
127+
![diff_lines](screens/diff_lines_format-color.png)
128+
129+
```rust
130+
use prettydiff::{diff_lines, text:ContextConfig};
131+
use owo_colors::Style;
132+
133+
let context = ContextConfig {
134+
context_size: 2,
135+
skipping_marker: "...",
136+
remove_color: Style::new().red().underline(),
137+
insert_color: Style::new().purple().bold(),
138+
};
139+
140+
let code1_a = r#"
141+
void func1() {
142+
x += 1
143+
}
144+
145+
void func2() {
146+
x += 2
147+
}
148+
"#;
149+
let code1_b = r#"
150+
void func1(a: u32) {
151+
x += 1
152+
}
153+
154+
void functhreehalves() {
155+
x += 1.5
156+
}
157+
158+
void func2() {
159+
x += 2
160+
}
161+
162+
void func3(){}
163+
"#;
164+
println!("diff_lines:");
165+
println!("{}", diff_lines(code1_a, code1_b).format_with_context(Some(context), true));
166+
```
24.9 KB
Loading

0 commit comments

Comments
 (0)