Skip to content

Commit d0fb136

Browse files
saeckielegaanz
authored andcommitted
Check that files of readme links are present and images have alt text
1 parent 726248b commit d0fb136

4 files changed

Lines changed: 411 additions & 107 deletions

File tree

Cargo.lock

Lines changed: 123 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ comrak = { version = "0.49.0", default-features = false }
1313
dirs = "6.0.0"
1414
dotenvy = "0.15.7"
1515
fontdb = "0.23.0"
16+
html5ever = "0.38.0"
17+
markup5ever_rcdom = "0.38.0"
1618
ignore = "0.4.25"
1719
jwt-simple = { version = "0.12", default-features = false, features = [
1820
"pure-rust",
1921
] }
2022
parking_lot = "0.12.5"
2123
pathdiff = "0.2.3"
24+
regex = "1.12.3"
2225
reqwest = { version = "0.12", features = ["json"] }
2326
serde = { version = "1.0", features = ["derive"] }
2427
serde_json = "1.0"

src/check/files.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::path::{Path, PathBuf};
1+
use std::path::{Component, Path, PathBuf};
22

33
use codespan_reporting::diagnostic::{Diagnostic, Label};
44
use ignore::overrides::Override;
@@ -69,3 +69,17 @@ pub fn forbid_font_files(
6969

7070
Ok(())
7171
}
72+
73+
/// Stips any any leading root components (`/` or `\`) of the path before
74+
/// joining it to the `root` path.
75+
///
76+
/// Absolute paths (starting with `/` or `\`) replace the complete path when
77+
/// `join`ed with a parent path.
78+
pub fn path_relative_to(root: &Path, path: &Path) -> PathBuf {
79+
let components = path
80+
.components()
81+
.skip_while(|c| matches!(c, Component::RootDir))
82+
.map(|c| Path::new(c.as_os_str()));
83+
84+
PathBuf::from_iter(std::iter::once(root).chain(components))
85+
}

0 commit comments

Comments
 (0)