mkdocs-easylinks-plugin 0.2.2__tar.gz → 0.3.0__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.
Files changed (21) hide show
  1. {mkdocs_easylinks_plugin-0.2.2 → mkdocs_easylinks_plugin-0.3.0}/PKG-INFO +44 -8
  2. {mkdocs_easylinks_plugin-0.2.2 → mkdocs_easylinks_plugin-0.3.0}/README.md +43 -7
  3. mkdocs_easylinks_plugin-0.3.0/mkdocs_easylinks/__init__.py +8 -0
  4. mkdocs_easylinks_plugin-0.3.0/mkdocs_easylinks/plugin.py +575 -0
  5. {mkdocs_easylinks_plugin-0.2.2 → mkdocs_easylinks_plugin-0.3.0}/mkdocs_easylinks_plugin.egg-info/PKG-INFO +44 -8
  6. {mkdocs_easylinks_plugin-0.2.2 → mkdocs_easylinks_plugin-0.3.0}/mkdocs_easylinks_plugin.egg-info/SOURCES.txt +0 -5
  7. {mkdocs_easylinks_plugin-0.2.2 → mkdocs_easylinks_plugin-0.3.0}/pyproject.toml +2 -2
  8. {mkdocs_easylinks_plugin-0.2.2 → mkdocs_easylinks_plugin-0.3.0}/tests/test_plugin.py +555 -6
  9. mkdocs_easylinks_plugin-0.2.2/.github/workflows/publish.yml +0 -30
  10. mkdocs_easylinks_plugin-0.2.2/.github/workflows/test.yml +0 -48
  11. mkdocs_easylinks_plugin-0.2.2/.gitignore +0 -48
  12. mkdocs_easylinks_plugin-0.2.2/CHANGELOG.md +0 -87
  13. mkdocs_easylinks_plugin-0.2.2/mkdocs_easylinks/__init__.py +0 -3
  14. mkdocs_easylinks_plugin-0.2.2/mkdocs_easylinks/plugin.py +0 -345
  15. mkdocs_easylinks_plugin-0.2.2/tests/__init__.py +0 -1
  16. {mkdocs_easylinks_plugin-0.2.2 → mkdocs_easylinks_plugin-0.3.0}/LICENSE +0 -0
  17. {mkdocs_easylinks_plugin-0.2.2 → mkdocs_easylinks_plugin-0.3.0}/mkdocs_easylinks_plugin.egg-info/dependency_links.txt +0 -0
  18. {mkdocs_easylinks_plugin-0.2.2 → mkdocs_easylinks_plugin-0.3.0}/mkdocs_easylinks_plugin.egg-info/entry_points.txt +0 -0
  19. {mkdocs_easylinks_plugin-0.2.2 → mkdocs_easylinks_plugin-0.3.0}/mkdocs_easylinks_plugin.egg-info/requires.txt +0 -0
  20. {mkdocs_easylinks_plugin-0.2.2 → mkdocs_easylinks_plugin-0.3.0}/mkdocs_easylinks_plugin.egg-info/top_level.txt +0 -0
  21. {mkdocs_easylinks_plugin-0.2.2 → mkdocs_easylinks_plugin-0.3.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-easylinks-plugin
3
- Version: 0.2.2
3
+ Version: 0.3.0
4
4
  Summary: An MkDocs plugin that allows linking to files by filename only
5
5
  Author: Daniel Ferguson
6
6
  License-Expression: MIT
@@ -69,6 +69,7 @@ plugins:
69
69
  show_stats: false # Show link statistics after build (default: false)
70
70
  protect_code_fences: true # Leave links inside fenced code blocks unchanged (default: true)
71
71
  protect_html_comments: true # Leave links inside HTML comments unchanged (default: true)
72
+ protect_inline_code: true # Leave links inside `code spans` unchanged (default: true)
72
73
  ```
73
74
 
74
75
  #### Available Options
@@ -80,6 +81,7 @@ plugins:
80
81
  - **`show_stats`** (bool, default: `false`): Display link statistics after the build completes
81
82
  - **`protect_code_fences`** (bool, default: `true`): When enabled, links inside fenced code blocks (` ``` ` or `~~~`) are left unchanged. Set to `false` to process them like normal content.
82
83
  - **`protect_html_comments`** (bool, default: `true`): When enabled, links inside HTML comments (`<!-- -->`) are left unchanged. Set to `false` to process them like normal content.
84
+ - **`protect_inline_code`** (bool, default: `true`): When enabled, links inside inline code spans (`` `like this` ``) are left unchanged. Set to `false` to process them like normal content.
83
85
 
84
86
  #### Ignoring Specific Files
85
87
 
@@ -127,8 +129,14 @@ This will display:
127
129
  - Files scanned, indexed, ambiguous, and ignored
128
130
  - Links processed, resolved, and unresolved
129
131
  - Images processed, resolved, and unresolved
130
- - Most frequently linked files
131
- - Orphaned files (indexed but never linked)
132
+ - Most frequently referenced files
133
+ - Orphaned files (indexed but never referenced)
134
+
135
+ > **Note:** Reference counts include both links and image embeds, but only those written as bare filenames — the form this plugin resolves. A file reached solely through an explicit relative path (`../images/logo.png`) is invisible to the plugin and will be listed as orphaned.
136
+ >
137
+ > The orphan list also covers every file MkDocs supplies, which includes your theme's own CSS, JavaScript and icons. Those are never referenced from your Markdown, so they will always be listed. Add them to `exclude_dirs` if the noise bothers you.
138
+
139
+ Statistics are written at `INFO` level, which MkDocs shows by default; `mkdocs build --quiet` suppresses them.
132
140
 
133
141
  ## Examples
134
142
 
@@ -176,6 +184,10 @@ Anchors work for document links:
176
184
  - `[text](filename.md)` - Simple document filenames
177
185
  - `[text](file.md#anchor)` - Document filenames with anchors
178
186
  - `![alt](image.png)` - Simple image filenames (png, jpg, svg, gif, etc.)
187
+ - `![](image.png)` - Images with no alt text
188
+ - `[text](file.md "Title")` - Destinations with a link title, which is preserved
189
+ - `[text](<file name.md>)` - Angle-bracketed destinations, which keep their brackets
190
+ - `[![alt](icon.png)](file.md)` - A linked image; both the image and the link resolve
179
191
 
180
192
  **Not processed** (left as-is):
181
193
  - `[text](https://example.com)` - External URLs
@@ -183,8 +195,14 @@ Anchors work for document links:
183
195
  - `[text](/absolute/path.md)` - Absolute paths
184
196
  - `[text](../relative/path.md)` - Explicit relative paths with directories
185
197
  - `[text](#anchor)` - Fragment-only links
198
+ - `[text](javascript:...)`, `[text](data:...)`, `[text](mailto:...)`, etc. — any destination containing a colon (treated as a scheme). The destination is checked with any `#fragment` removed, so a colon inside an anchor is not mistaken for a scheme.
199
+ - `[text][ref]` with a `[ref]: file.md` definition — reference-style links are not resolved
200
+ - `[text](file.md?query=1)` - Destinations carrying a query string
186
201
  - Links/images inside code fences (` ``` ` or `~~~`) — unless `protect_code_fences: false`
187
202
  - Links/images inside HTML comments (`<!-- -->`) — unless `protect_html_comments: false`
203
+ - Links/images inside inline code spans (`` `like this` ``) — unless `protect_inline_code: false`
204
+
205
+ > **Security note:** easylinks does not sanitize link targets. Schemed URLs (including `javascript:` and `data:`) are passed through unchanged for the Markdown renderer to handle. XSS protection in your rendered site is the responsibility of MkDocs and the Markdown extensions you have configured — not this plugin.
188
206
 
189
207
  ### Protected Content
190
208
 
@@ -202,19 +220,37 @@ The plugin intelligently ignores links in:
202
220
  <!-- This [link](example.md) won't be processed -->
203
221
  ```
204
222
 
205
- This ensures that example code and commented-out content remain unchanged. Both behaviours are configurable via `protect_code_fences` and `protect_html_comments`.
223
+ **Inline code spans:**
224
+ ````markdown
225
+ Write `[link](example.md)` to reference a file.
226
+ ````
227
+
228
+ A code span is closed by a backtick run of the same length, and never spans a
229
+ blank line — so a stray backtick in your prose is harmless.
230
+
231
+ This ensures that example code and commented-out content remain unchanged. All three behaviours are configurable via `protect_code_fences`, `protect_html_comments` and `protect_inline_code`.
232
+
233
+ Fences are matched the way a Markdown renderer matches them:
234
+
235
+ - A fence is closed only by the same character, repeated at least as many times, alone on its line. So a ` ```` ` block can contain ` ``` ` blocks — useful for documenting fenced syntax itself.
236
+ - A fence with no closing fence extends to the end of the document.
237
+ - Fences are recognised at any indentation, so a code block nested inside a list item or an admonition is protected.
206
238
 
207
239
  **Important: Indented Content**
208
240
 
209
- Only explicit code fences (``` or ~~~) are protected. Indented content, such as in MkDocs admonitions, **is processed normally**:
241
+ Only explicit code fences (``` or ~~~) are protected. Indented *prose*, such as the body of a MkDocs admonition, **is processed normally**:
210
242
 
211
- ```markdown
243
+ ````markdown
212
244
  !!! note
213
245
  This [link](guide.md) WILL be processed.
214
246
  The plugin works inside admonitions!
215
- ```
216
247
 
217
- This design choice ensures the plugin works seamlessly with MkDocs features like admonitions, which rely heavily on indentation.
248
+ ```
249
+ But this [link](guide.md) will NOT be — it is a fence.
250
+ ```
251
+ ````
252
+
253
+ This design choice ensures the plugin works seamlessly with MkDocs features like admonitions, which rely heavily on indentation, while still leaving genuine code samples alone.
218
254
 
219
255
  ## How It Works
220
256
 
@@ -42,6 +42,7 @@ plugins:
42
42
  show_stats: false # Show link statistics after build (default: false)
43
43
  protect_code_fences: true # Leave links inside fenced code blocks unchanged (default: true)
44
44
  protect_html_comments: true # Leave links inside HTML comments unchanged (default: true)
45
+ protect_inline_code: true # Leave links inside `code spans` unchanged (default: true)
45
46
  ```
46
47
 
47
48
  #### Available Options
@@ -53,6 +54,7 @@ plugins:
53
54
  - **`show_stats`** (bool, default: `false`): Display link statistics after the build completes
54
55
  - **`protect_code_fences`** (bool, default: `true`): When enabled, links inside fenced code blocks (` ``` ` or `~~~`) are left unchanged. Set to `false` to process them like normal content.
55
56
  - **`protect_html_comments`** (bool, default: `true`): When enabled, links inside HTML comments (`<!-- -->`) are left unchanged. Set to `false` to process them like normal content.
57
+ - **`protect_inline_code`** (bool, default: `true`): When enabled, links inside inline code spans (`` `like this` ``) are left unchanged. Set to `false` to process them like normal content.
56
58
 
57
59
  #### Ignoring Specific Files
58
60
 
@@ -100,8 +102,14 @@ This will display:
100
102
  - Files scanned, indexed, ambiguous, and ignored
101
103
  - Links processed, resolved, and unresolved
102
104
  - Images processed, resolved, and unresolved
103
- - Most frequently linked files
104
- - Orphaned files (indexed but never linked)
105
+ - Most frequently referenced files
106
+ - Orphaned files (indexed but never referenced)
107
+
108
+ > **Note:** Reference counts include both links and image embeds, but only those written as bare filenames — the form this plugin resolves. A file reached solely through an explicit relative path (`../images/logo.png`) is invisible to the plugin and will be listed as orphaned.
109
+ >
110
+ > The orphan list also covers every file MkDocs supplies, which includes your theme's own CSS, JavaScript and icons. Those are never referenced from your Markdown, so they will always be listed. Add them to `exclude_dirs` if the noise bothers you.
111
+
112
+ Statistics are written at `INFO` level, which MkDocs shows by default; `mkdocs build --quiet` suppresses them.
105
113
 
106
114
  ## Examples
107
115
 
@@ -149,6 +157,10 @@ Anchors work for document links:
149
157
  - `[text](filename.md)` - Simple document filenames
150
158
  - `[text](file.md#anchor)` - Document filenames with anchors
151
159
  - `![alt](image.png)` - Simple image filenames (png, jpg, svg, gif, etc.)
160
+ - `![](image.png)` - Images with no alt text
161
+ - `[text](file.md "Title")` - Destinations with a link title, which is preserved
162
+ - `[text](<file name.md>)` - Angle-bracketed destinations, which keep their brackets
163
+ - `[![alt](icon.png)](file.md)` - A linked image; both the image and the link resolve
152
164
 
153
165
  **Not processed** (left as-is):
154
166
  - `[text](https://example.com)` - External URLs
@@ -156,8 +168,14 @@ Anchors work for document links:
156
168
  - `[text](/absolute/path.md)` - Absolute paths
157
169
  - `[text](../relative/path.md)` - Explicit relative paths with directories
158
170
  - `[text](#anchor)` - Fragment-only links
171
+ - `[text](javascript:...)`, `[text](data:...)`, `[text](mailto:...)`, etc. — any destination containing a colon (treated as a scheme). The destination is checked with any `#fragment` removed, so a colon inside an anchor is not mistaken for a scheme.
172
+ - `[text][ref]` with a `[ref]: file.md` definition — reference-style links are not resolved
173
+ - `[text](file.md?query=1)` - Destinations carrying a query string
159
174
  - Links/images inside code fences (` ``` ` or `~~~`) — unless `protect_code_fences: false`
160
175
  - Links/images inside HTML comments (`<!-- -->`) — unless `protect_html_comments: false`
176
+ - Links/images inside inline code spans (`` `like this` ``) — unless `protect_inline_code: false`
177
+
178
+ > **Security note:** easylinks does not sanitize link targets. Schemed URLs (including `javascript:` and `data:`) are passed through unchanged for the Markdown renderer to handle. XSS protection in your rendered site is the responsibility of MkDocs and the Markdown extensions you have configured — not this plugin.
161
179
 
162
180
  ### Protected Content
163
181
 
@@ -175,19 +193,37 @@ The plugin intelligently ignores links in:
175
193
  <!-- This [link](example.md) won't be processed -->
176
194
  ```
177
195
 
178
- This ensures that example code and commented-out content remain unchanged. Both behaviours are configurable via `protect_code_fences` and `protect_html_comments`.
196
+ **Inline code spans:**
197
+ ````markdown
198
+ Write `[link](example.md)` to reference a file.
199
+ ````
200
+
201
+ A code span is closed by a backtick run of the same length, and never spans a
202
+ blank line — so a stray backtick in your prose is harmless.
203
+
204
+ This ensures that example code and commented-out content remain unchanged. All three behaviours are configurable via `protect_code_fences`, `protect_html_comments` and `protect_inline_code`.
205
+
206
+ Fences are matched the way a Markdown renderer matches them:
207
+
208
+ - A fence is closed only by the same character, repeated at least as many times, alone on its line. So a ` ```` ` block can contain ` ``` ` blocks — useful for documenting fenced syntax itself.
209
+ - A fence with no closing fence extends to the end of the document.
210
+ - Fences are recognised at any indentation, so a code block nested inside a list item or an admonition is protected.
179
211
 
180
212
  **Important: Indented Content**
181
213
 
182
- Only explicit code fences (``` or ~~~) are protected. Indented content, such as in MkDocs admonitions, **is processed normally**:
214
+ Only explicit code fences (``` or ~~~) are protected. Indented *prose*, such as the body of a MkDocs admonition, **is processed normally**:
183
215
 
184
- ```markdown
216
+ ````markdown
185
217
  !!! note
186
218
  This [link](guide.md) WILL be processed.
187
219
  The plugin works inside admonitions!
188
- ```
189
220
 
190
- This design choice ensures the plugin works seamlessly with MkDocs features like admonitions, which rely heavily on indentation.
221
+ ```
222
+ But this [link](guide.md) will NOT be — it is a fence.
223
+ ```
224
+ ````
225
+
226
+ This design choice ensures the plugin works seamlessly with MkDocs features like admonitions, which rely heavily on indentation, while still leaving genuine code samples alone.
191
227
 
192
228
  ## How It Works
193
229
 
@@ -0,0 +1,8 @@
1
+ """MkDocs EasyLinks Plugin - Simplified cross-referencing by filename."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ try:
6
+ __version__ = version("mkdocs-easylinks-plugin")
7
+ except PackageNotFoundError: # pragma: no cover
8
+ __version__ = "unknown"