You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Thanks a lot for your interest in contributing to **markdownlint-rule-relative-l
4
4
5
5
## Code of Conduct
6
6
7
-
**markdownlint-rule-relative-links** adopted the [Contributor Covenant](https://www.contributor-covenant.org/) as its Code of Conduct, and we expect project participants to adhere to it. Please read [the full text](./CODE_OF_CONDUCT.md) so that you can understand what actions will and will not be tolerated.
7
+
**markdownlint-rule-relative-links** adopted the [Contributor Covenant](https://www.contributor-covenant.org/) as its Code of Conduct, and we expect project participants to adhere to it. Please read [the full text](/CODE_OF_CONDUCT.md) so that you can understand what actions will and will not be tolerated.
Copy file name to clipboardExpand all lines: README.md
+23-3Lines changed: 23 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,12 +51,13 @@ awesome.md:3 relative-links Relative links should be valid ["./invalid.txt" shou
51
51
- Support images (e.g: ``).
52
52
- Support links fragments similar to the [built-in `markdownlint` rule - MD051](https://github.com/DavidAnson/markdownlint/blob/main/doc/md051.md) (e.g: `[Link](./awesome.md#heading)`).
53
53
- Ignore external links and absolute paths as it only checks relative links (e.g: `https://example.com/` or `/absolute/path.png`).
54
+
- If necessary, absolute paths can be validated too, with [`root_path` configuration option](#absolute-paths).
54
55
55
56
### Limitations
56
57
57
58
- Only images and links defined using markdown syntax are validated, html syntax is ignored (e.g: `<a href="./link.txt" />` or `<img src="./image.png" />`).
58
59
59
-
Contributions are welcome to improve the rule, and to alleviate these limitations. See [CONTRIBUTING.md](./CONTRIBUTING.md) for more information.
60
+
Contributions are welcome to improve the rule, and to alleviate these limitations. See [CONTRIBUTING.md](/CONTRIBUTING.md) for more information.
60
61
61
62
### Related links
62
63
@@ -108,6 +109,25 @@ export default config
108
109
}
109
110
```
110
111
112
+
### Absolute paths
113
+
114
+
GitHub (and, likely, other similar platforms) resolves absolute paths in Markdown links relative to the repository root.
115
+
116
+
To validate such links, add `root_path` option to the configuration:
117
+
118
+
```js
119
+
config: {
120
+
default:true,
121
+
"relative-links": {
122
+
root_path:".",
123
+
},
124
+
},
125
+
```
126
+
127
+
After this change, all absolute paths will be converted to relative paths, and will be resolved relative to the specified directory.
128
+
129
+
For example, if you run markdownlint from a subdirectory (if `package.json` is located in a subdirectory), you should set `root_path` to `".."`.
130
+
111
131
## Usage
112
132
113
133
```sh
@@ -118,8 +138,8 @@ node --run lint:markdown
118
138
119
139
Anyone can help to improve the project, submit a Feature Request, a bug report or even correct a simple spelling mistake.
120
140
121
-
The steps to contribute can be found in the [CONTRIBUTING.md](./CONTRIBUTING.md) file.
141
+
The steps to contribute can be found in the [CONTRIBUTING.md](/CONTRIBUTING.md) file.
0 commit comments