mdrefcheck 0.1.6__tar.gz → 0.1.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mdrefcheck might be problematic. Click here for more details.

@@ -122,6 +122,12 @@ dependencies = [
122
122
  "windows-sys 0.59.0",
123
123
  ]
124
124
 
125
+ [[package]]
126
+ name = "dunce"
127
+ version = "1.0.5"
128
+ source = "registry+https://github.com/rust-lang/crates.io-index"
129
+ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
130
+
125
131
  [[package]]
126
132
  name = "getopts"
127
133
  version = "0.2.23"
@@ -145,10 +151,11 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
145
151
 
146
152
  [[package]]
147
153
  name = "mdrefcheck"
148
- version = "0.1.6"
154
+ version = "0.1.7"
149
155
  dependencies = [
150
156
  "clap",
151
157
  "colored",
158
+ "dunce",
152
159
  "pathdiff",
153
160
  "pulldown-cmark",
154
161
  "regex",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "mdrefcheck"
3
- version = "0.1.6"
3
+ version = "0.1.7"
4
4
  edition = "2024"
5
5
  readme = "README.md"
6
6
  description = "A CLI tool to validate references in markdown files."
@@ -14,6 +14,7 @@ categories = ["command-line-utilities", "development-tools"]
14
14
  [dependencies]
15
15
  clap = { version = "4.5.47", features = ["derive"] }
16
16
  colored = "3.0.0"
17
+ dunce = "1.0.5"
17
18
  pathdiff = "0.2.3"
18
19
  pulldown-cmark = "0.13.0"
19
20
  regex = "1.11.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mdrefcheck
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Environment :: Console
6
6
  Classifier: Intended Audience :: Developers
@@ -21,51 +21,49 @@ Project-URL: Repository, https://github.com/gospodima/mdrefcheck
21
21
 
22
22
  # mdrefcheck
23
23
 
24
+ [![PyPI version](https://img.shields.io/pypi/v/mdrefcheck.svg?logo=pypi&logoColor=white)](https://pypi.org/project/mdrefcheck/)
25
+ [![crates.io version](https://img.shields.io/crates/v/mdrefcheck.svg?logo=rust&logoColor=white)](https://crates.io/crates/mdrefcheck)
26
+ [![Build Status](https://github.com/gospodima/mdrefcheck/actions/workflows/ci.yml/badge.svg)](https://github.com/gospodima/mdrefcheck/actions/workflows/ci.yml)
27
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
28
+
24
29
  A CLI tool to validate references and links in Markdown files (CommonMark spec).
25
30
  It helps to ensure that your documentation is free from broken section links, missing images or files.
26
31
 
27
32
  ## Features
28
33
 
29
- - Validate local file paths in image and section references
30
- - Check section links (`#heading-link`) match existing headings according to [GitHub Flavored Markdown (GFM)](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links) rules
31
- - Identify broken reference-style links
32
- - Email validation
34
+ - Validate local file paths in image and file references
35
+ - Check section links against actual headings, following [GitHub Flavored Markdown (GFM)](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links) rules, including cross-file references (e.g. `./subfolder/another-file.md#heading-link`)
36
+ - Detect broken reference-style links
37
+ - Basic email validation
33
38
 
34
39
  ## Installation
35
40
 
36
41
  ### Cargo
37
42
 
38
- `mdrefcheck` is also published on [crates.io](https://crates.io/) and can be installed
39
- with cargo:
40
-
41
43
  ```bash
42
44
  cargo install mdrefcheck
43
45
  ```
44
46
 
45
47
  ### PyPI
46
48
 
47
- `mdrefcheck` can be installed with
48
-
49
49
  ```bash
50
50
  pip install mdrefcheck
51
51
  ```
52
52
 
53
- It also can be used as a tool in an isolated environment, e.g., with `uvx`:
53
+ or run it directly in an isolated environment, e.g., with `uvx`:
54
54
 
55
55
  ```bash
56
56
  uvx mdrefcheck .
57
57
  ```
58
58
 
59
- ### Pre-commit integration
60
-
61
- You can use `mdrefcheck` as a pre-commit hook.
59
+ ## Pre-commit integration
62
60
 
63
61
  Add this to your `.pre-commit-config.yaml`:
64
62
 
65
63
  ```yaml
66
64
  repos:
67
65
  - repo: https://github.com/gospodima/mdrefcheck
68
- rev: v0.1.6
66
+ rev: v0.1.7
69
67
  hooks:
70
68
  - id: mdrefcheck
71
69
  ```
@@ -0,0 +1,48 @@
1
+ # mdrefcheck
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/mdrefcheck.svg?logo=pypi&logoColor=white)](https://pypi.org/project/mdrefcheck/)
4
+ [![crates.io version](https://img.shields.io/crates/v/mdrefcheck.svg?logo=rust&logoColor=white)](https://crates.io/crates/mdrefcheck)
5
+ [![Build Status](https://github.com/gospodima/mdrefcheck/actions/workflows/ci.yml/badge.svg)](https://github.com/gospodima/mdrefcheck/actions/workflows/ci.yml)
6
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
7
+
8
+ A CLI tool to validate references and links in Markdown files (CommonMark spec).
9
+ It helps to ensure that your documentation is free from broken section links, missing images or files.
10
+
11
+ ## Features
12
+
13
+ - Validate local file paths in image and file references
14
+ - Check section links against actual headings, following [GitHub Flavored Markdown (GFM)](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links) rules, including cross-file references (e.g. `./subfolder/another-file.md#heading-link`)
15
+ - Detect broken reference-style links
16
+ - Basic email validation
17
+
18
+ ## Installation
19
+
20
+ ### Cargo
21
+
22
+ ```bash
23
+ cargo install mdrefcheck
24
+ ```
25
+
26
+ ### PyPI
27
+
28
+ ```bash
29
+ pip install mdrefcheck
30
+ ```
31
+
32
+ or run it directly in an isolated environment, e.g., with `uvx`:
33
+
34
+ ```bash
35
+ uvx mdrefcheck .
36
+ ```
37
+
38
+ ## Pre-commit integration
39
+
40
+ Add this to your `.pre-commit-config.yaml`:
41
+
42
+ ```yaml
43
+ repos:
44
+ - repo: https://github.com/gospodima/mdrefcheck
45
+ rev: v0.1.7
46
+ hooks:
47
+ - id: mdrefcheck
48
+ ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mdrefcheck"
3
- version = "0.1.6"
3
+ version = "0.1.7"
4
4
  description = "A CLI tool to validate references in markdown files."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -8,9 +8,8 @@ pub fn validate_email(email: &str) -> Result<(), String> {
8
8
  }
9
9
  }
10
10
 
11
-
12
11
  /// Email validation according to https://spec.commonmark.org/0.31.2/#email-address
13
12
  fn is_valid_email(s: &str) -> bool {
14
13
  static EMAIL_RE: &str = r"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$";
15
14
  Regex::new(EMAIL_RE).unwrap().is_match(s)
16
- }
15
+ }
@@ -1,6 +1,6 @@
1
1
  use crate::utils::relative_path;
2
- use std::path::Path;
3
2
  use colored::Colorize;
3
+ use std::path::Path;
4
4
 
5
5
  /// Represents a markdown validation issue (Ruff-compatible output)
6
6
  pub struct ValidationError {
@@ -11,7 +11,12 @@ pub struct ValidationError {
11
11
  }
12
12
 
13
13
  impl ValidationError {
14
- pub fn new(path: &Path, line: usize, col: usize, message: impl Into<String>) -> Self {
14
+ pub fn new(
15
+ path: &Path,
16
+ line: usize,
17
+ col: usize,
18
+ message: impl Into<String>,
19
+ ) -> Self {
15
20
  Self {
16
21
  path: relative_path(path),
17
22
  line,
@@ -23,6 +28,13 @@ impl ValidationError {
23
28
 
24
29
  impl std::fmt::Display for ValidationError {
25
30
  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26
- write!(f, "{}:{}:{}: {}", self.path.bold(), self.line, self.col, self.message)
31
+ write!(
32
+ f,
33
+ "{}:{}:{}: {}",
34
+ self.path.bold(),
35
+ self.line,
36
+ self.col,
37
+ self.message
38
+ )
27
39
  }
28
40
  }
@@ -10,7 +10,7 @@ pub fn create_options() -> Options {
10
10
  Options::ENABLE_FOOTNOTES | Options::ENABLE_WIKILINKS
11
11
  }
12
12
 
13
- /// Create HashSet of canonicalized paths from vector of paths
13
+ /// Create HashSet of canonicalized paths from vector of paths
14
14
  pub fn create_file_set(vec_files: &Vec<PathBuf>) -> HashSet<PathBuf> {
15
15
  vec_files
16
16
  .iter()
@@ -18,11 +18,16 @@ pub fn create_file_set(vec_files: &Vec<PathBuf>) -> HashSet<PathBuf> {
18
18
  .collect()
19
19
  }
20
20
 
21
- /// Return a path relative to current working directory
21
+ /// Return a path relative to the current working directory
22
22
  pub fn relative_path(target: &Path) -> String {
23
23
  let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
24
- pathdiff::diff_paths(target, cwd)
25
- .unwrap_or_else(|| target.to_path_buf())
24
+
25
+ // Normalize target path first (fixes Windows \\?\ prefixes)
26
+ let normalized =
27
+ dunce::canonicalize(target).unwrap_or_else(|_| target.to_path_buf());
28
+
29
+ pathdiff::diff_paths(&normalized, cwd)
30
+ .unwrap_or(normalized)
26
31
  .display()
27
32
  .to_string()
28
33
  }
@@ -1,50 +0,0 @@
1
- # mdrefcheck
2
-
3
- A CLI tool to validate references and links in Markdown files (CommonMark spec).
4
- It helps to ensure that your documentation is free from broken section links, missing images or files.
5
-
6
- ## Features
7
-
8
- - Validate local file paths in image and section references
9
- - Check section links (`#heading-link`) match existing headings according to [GitHub Flavored Markdown (GFM)](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links) rules
10
- - Identify broken reference-style links
11
- - Email validation
12
-
13
- ## Installation
14
-
15
- ### Cargo
16
-
17
- `mdrefcheck` is also published on [crates.io](https://crates.io/) and can be installed
18
- with cargo:
19
-
20
- ```bash
21
- cargo install mdrefcheck
22
- ```
23
-
24
- ### PyPI
25
-
26
- `mdrefcheck` can be installed with
27
-
28
- ```bash
29
- pip install mdrefcheck
30
- ```
31
-
32
- It also can be used as a tool in an isolated environment, e.g., with `uvx`:
33
-
34
- ```bash
35
- uvx mdrefcheck .
36
- ```
37
-
38
- ### Pre-commit integration
39
-
40
- You can use `mdrefcheck` as a pre-commit hook.
41
-
42
- Add this to your `.pre-commit-config.yaml`:
43
-
44
- ```yaml
45
- repos:
46
- - repo: https://github.com/gospodima/mdrefcheck
47
- rev: v0.1.6
48
- hooks:
49
- - id: mdrefcheck
50
- ```
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes