Skip to content

Commit ffdcb98

Browse files
authored
Merge pull request #2619 from rust-lang/tshepang/reformat-some-tests-chapters
fix another corner case for sembr tool
2 parents ed42b29 + 7945a7b commit ffdcb98

File tree

3 files changed

+132
-106
lines changed

3 files changed

+132
-106
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ jobs:
8787
continue-on-error: true
8888
run: |
8989
# using split_inclusive that uses regex feature that uses an unstable feature
90-
RUSTC_BOOTSTRAP=true cargo run --manifest-path ci/sembr/Cargo.toml src
90+
RUSTC_BOOTSTRAP=1 cargo run --manifest-path ci/sembr/Cargo.toml src

ci/sembr/src/main.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ struct Cli {
2222
static REGEX_IGNORE: LazyLock<Regex> =
2323
LazyLock::new(|| Regex::new(r"^\s*(\d\.|\-|\*)\s+").unwrap());
2424
static REGEX_IGNORE_END: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(\.|\?|;|!)$").unwrap());
25+
static REGEX_IGNORE_LINK_TARGETS: LazyLock<Regex> =
26+
LazyLock::new(|| Regex::new(r"^\[.+\]: ").unwrap());
2527
static REGEX_SPLIT: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(\.|\?|;|!)\s+").unwrap());
2628

2729
fn main() -> Result<()> {
@@ -94,6 +96,7 @@ fn ignore(line: &str, in_code_block: bool) -> bool {
9496
|| line.starts_with('#')
9597
|| line.trim().is_empty()
9698
|| REGEX_IGNORE.is_match(line)
99+
|| REGEX_IGNORE_LINK_TARGETS.is_match(line)
97100
}
98101

99102
fn comply(content: &str) -> String {
@@ -221,6 +224,15 @@ fn test_prettify_prefix_spaces() {
221224
assert_eq!(expected, lengthen_lines(original, 50));
222225
}
223226

227+
#[test]
228+
fn test_prettify_ignore_link_targets() {
229+
let original = "\
230+
[a target]: https://example.com
231+
[another target]: https://example.com
232+
";
233+
assert_eq!(original, lengthen_lines(original, 100));
234+
}
235+
224236
#[test]
225237
fn test_sembr_then_prettify() {
226238
let original = "\

0 commit comments

Comments
 (0)