Skip to content

Commit b271341

Browse files
committed
sembr: handle text inside div blocks
The hackiness of this tool is getting more and more embarassing
1 parent 299a13b commit b271341

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/doc/rustc-dev-guide/ci/sembr/src/main.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ fn lengthen_lines(content: &str, limit: usize) -> String {
137137
let mut new_content = content.clone();
138138
let mut new_n = 0;
139139
let mut in_code_block = false;
140+
let mut in_html_div = false;
140141
let mut skip_next = false;
141142
for (n, line) in content.iter().enumerate() {
142143
if skip_next {
@@ -150,6 +151,17 @@ fn lengthen_lines(content: &str, limit: usize) -> String {
150151
in_code_block = !in_code_block;
151152
continue;
152153
}
154+
if line.trim_start().starts_with("<div") {
155+
in_html_div = true;
156+
continue;
157+
}
158+
if line.trim_start().starts_with("</div") {
159+
in_html_div = false;
160+
continue;
161+
}
162+
if in_html_div {
163+
continue;
164+
}
153165
if ignore(line, in_code_block) || REGEX_SPLIT.is_match(line) {
154166
continue;
155167
}
@@ -215,9 +227,15 @@ fn test_prettify() {
215227
let original = "\
216228
do not split
217229
short sentences
230+
<div class='warning'>
231+
a bit of text inside
232+
</div>
218233
";
219234
let expected = "\
220235
do not split short sentences
236+
<div class='warning'>
237+
a bit of text inside
238+
</div>
221239
";
222240
assert_eq!(expected, lengthen_lines(original, 50));
223241
}

src/doc/rustc-dev-guide/src/tests/running.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ therefore, while the tests **usually** work fine with stage 1, there are some li
127127
./x test --stage 2
128128
```
129129

130-
<div class="warning"> You almost never need to do this;
130+
<div class="warning">
131+
You almost never need to do this;
131132
CI will run these tests for you.
132133
</div>
133134

0 commit comments

Comments
 (0)