mkdocs-alias-plugin 0.8.0__tar.gz → 0.8.2__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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: mkdocs-alias-plugin
3
- Version: 0.8.0
3
+ Version: 0.8.2
4
4
  Summary: An MkDocs plugin allowing links to your pages using a custom alias
5
5
  Home-page: https://github.com/eddyluten/mkdocs-alias-plugin
6
6
  Author: Eddy Luten
@@ -20,10 +20,21 @@ Description-Content-Type: text/markdown
20
20
  License-File: LICENSE.md
21
21
  Requires-Dist: mkdocs
22
22
  Requires-Dist: markdown
23
+ Dynamic: author
24
+ Dynamic: author-email
25
+ Dynamic: classifier
26
+ Dynamic: description
27
+ Dynamic: description-content-type
28
+ Dynamic: home-page
29
+ Dynamic: keywords
30
+ Dynamic: license
31
+ Dynamic: requires-dist
32
+ Dynamic: requires-python
33
+ Dynamic: summary
23
34
 
24
35
  # mkdocs-alias-plugin
25
36
 
26
- [![PyPI version](https://badge.fury.io/py/mkdocs-alias-plugin.svg)](https://pypi.org/project/mkdocs-alias-plugin/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ![example workflow](https://github.com/eddyluten/mkdocs-alias-plugin/actions/workflows/pylint.yml/badge.svg) [![Downloads](https://pepy.tech/badge/mkdocs-alias-plugin)](https://pepy.tech/project/mkdocs-alias-plugin) ![](https://github.com/eddyluten/mkdocs-alias-plugin/workflows/mkdocs-alias-plugin%20Tests/badge.svg)
37
+ [![PyPI version](https://badge.fury.io/py/mkdocs-alias-plugin.svg)](https://pypi.org/project/mkdocs-alias-plugin/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Downloads](https://pepy.tech/badge/mkdocs-alias-plugin)](https://pepy.tech/project/mkdocs-alias-plugin) [![CI](https://github.com/eddyluten/mkdocs-alias-plugin/workflows/mkdocs-alias-plugin%20CI/badge.svg)](https://github.com/EddyLuten/mkdocs-alias-plugin/actions/workflows/ci.yml)
27
38
 
28
39
  The `mkdocs-alias-plugin` MkDocs plugin allows links to your pages using a custom alias such as `[[my-alias]]` or `[[my-alias|My Title]]`.
29
40
 
@@ -100,6 +111,8 @@ The song references [[wuthering-heights#references|Wuthering Heights]].
100
111
 
101
112
  As of version 0.8.0, you can enable the plugin option `use_anchor_titles` to replace anchor links with the text of the page heading that defined it. This behavior is opt-in to preserve backward compatibility.
102
113
 
114
+ As of version 0.9.0, you may also use `aliases` in addition to (or in place of) the `alias` key in the meta section of your pages. This is to provide some similarity to other Markdown based software that supports aliases, such as Obsidian.
115
+
103
116
  Please refer to the [MkDocs documentation](https://www.mkdocs.org/user-guide/writing-your-docs/#yaml-style-meta-data) for more information on how the meta-data block is used.
104
117
 
105
118
  ### Multiple Aliases
@@ -134,16 +147,23 @@ plugins:
134
147
  - alias:
135
148
  verbose: true
136
149
  use_anchor_titles: true
150
+ use_page_icon: true
137
151
  ```
138
152
 
139
153
  ### `verbose`
140
154
 
141
- You may use the optional `verbose` option to print more information about which aliases were used and defined during the build process. The default value is `false`.
155
+ You may use the optional `verbose` option to print more information about which aliases were used and defined during the build process. A tab-delimited file named `aliases.log` will also be defined at the project root, containing a list of every alias defined by the wiki.
156
+
157
+ The default value is `false` and should only be enabled when debugging issue with the plugin.
142
158
 
143
159
  ### `use_anchor_titles`
144
160
 
145
161
  Setting this flag to true causes the plugin to replace an alias containing an anchor (`[[my-page#sub-heading]]`) with the text of the header that defined it. You can still override the title of the link as usual.
146
162
 
163
+ ### `use_page_icons`
164
+
165
+ Setting this flag to true will include the [page's icon](https://squidfunk.github.io/mkdocs-material/reference/?h=page+icon#setting-the-page-icon) in the alias substitution if it's set for a given page.
166
+
147
167
  ## Troubleshooting
148
168
 
149
169
  ### The link text looks like a path or URL
@@ -168,6 +188,13 @@ Aliases *must* be unique. Ensure that you're not redefining the same alias for a
168
188
 
169
189
  ## Local Development
170
190
 
191
+ Upgrade pip and install the dependencies:
192
+
193
+ ```zsh
194
+ python -m pip install --upgrade pip
195
+ pip install mkdocs pytest pylint markdown setuptools
196
+ ```
197
+
171
198
  Installing a local copy of the plugin:
172
199
 
173
200
  ```zsh
@@ -188,12 +215,33 @@ pylint $(git ls-files '*.py') && pytest -vv
188
215
 
189
216
  ## Changelog
190
217
 
218
+ ## 0.9.0
219
+
220
+ 2025-02-21
221
+
222
+ **Features and Bug Fixes:**
223
+
224
+ - Added the ability to use alias style links to anchors withing the current page, e.g.: `[[#my-anchor]]`.
225
+ - Added support for page icons in link aliases, thank you @joapuiib for your [contribution](https://github.com/EddyLuten/mkdocs-alias-plugin/pull/15)!
226
+ - Added support for using the key `alias` and/or `aliases` for defining page aliases in meta sections.
227
+ - Changed verbose mode to now also generates a tab-delimited log file containing each alias in the wiki.
228
+
229
+ ## 0.8.1
230
+
231
+ 2024-04-08
232
+
233
+ **Bug Fix:** fixes a bug where annotations would break older versions of Python 3. Bug report: [#9](https://github.com/EddyLuten/mkdocs-alias-plugin/issues/9).
234
+
191
235
  ## 0.8.0
192
236
 
237
+ 2024-04-06
238
+
193
239
  This release adds functionality to replace the titles of aliases containing anchors with the text of the heading that defines them. Enable this feature by setting the plugin option `use_anchor_titles` to true. Feature request: [#8](https://github.com/EddyLuten/mkdocs-alias-plugin/issues/8).
194
240
 
195
241
  ### 0.7.1
196
242
 
243
+ 2024-04-07
244
+
197
245
  **Bug Fix:** fixes a bug where any alias with the word "text" would break the plugin due to faulty logic. Bug report: [#7](https://github.com/EddyLuten/mkdocs-alias-plugin/issues/7).
198
246
 
199
247
  ### 0.7.0
@@ -1,29 +1,6 @@
1
- Metadata-Version: 2.1
2
- Name: mkdocs-alias-plugin
3
- Version: 0.8.0
4
- Summary: An MkDocs plugin allowing links to your pages using a custom alias
5
- Home-page: https://github.com/eddyluten/mkdocs-alias-plugin
6
- Author: Eddy Luten
7
- Author-email: eddyluten@gmail.com
8
- License: MIT
9
- Keywords: mkdocs python markdown alias link wiki
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python
12
- Classifier: Programming Language :: Python :: 3 :: Only
13
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
- Classifier: Topic :: Documentation
15
- Classifier: Topic :: Text Processing
16
- Classifier: Topic :: Text Processing :: Markup
17
- Classifier: Topic :: Text Processing :: Markup :: Markdown
18
- Requires-Python: >=3.0
19
- Description-Content-Type: text/markdown
20
- License-File: LICENSE.md
21
- Requires-Dist: mkdocs
22
- Requires-Dist: markdown
23
-
24
1
  # mkdocs-alias-plugin
25
2
 
26
- [![PyPI version](https://badge.fury.io/py/mkdocs-alias-plugin.svg)](https://pypi.org/project/mkdocs-alias-plugin/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ![example workflow](https://github.com/eddyluten/mkdocs-alias-plugin/actions/workflows/pylint.yml/badge.svg) [![Downloads](https://pepy.tech/badge/mkdocs-alias-plugin)](https://pepy.tech/project/mkdocs-alias-plugin) ![](https://github.com/eddyluten/mkdocs-alias-plugin/workflows/mkdocs-alias-plugin%20Tests/badge.svg)
3
+ [![PyPI version](https://badge.fury.io/py/mkdocs-alias-plugin.svg)](https://pypi.org/project/mkdocs-alias-plugin/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Downloads](https://pepy.tech/badge/mkdocs-alias-plugin)](https://pepy.tech/project/mkdocs-alias-plugin) [![CI](https://github.com/eddyluten/mkdocs-alias-plugin/workflows/mkdocs-alias-plugin%20CI/badge.svg)](https://github.com/EddyLuten/mkdocs-alias-plugin/actions/workflows/ci.yml)
27
4
 
28
5
  The `mkdocs-alias-plugin` MkDocs plugin allows links to your pages using a custom alias such as `[[my-alias]]` or `[[my-alias|My Title]]`.
29
6
 
@@ -100,6 +77,8 @@ The song references [[wuthering-heights#references|Wuthering Heights]].
100
77
 
101
78
  As of version 0.8.0, you can enable the plugin option `use_anchor_titles` to replace anchor links with the text of the page heading that defined it. This behavior is opt-in to preserve backward compatibility.
102
79
 
80
+ As of version 0.9.0, you may also use `aliases` in addition to (or in place of) the `alias` key in the meta section of your pages. This is to provide some similarity to other Markdown based software that supports aliases, such as Obsidian.
81
+
103
82
  Please refer to the [MkDocs documentation](https://www.mkdocs.org/user-guide/writing-your-docs/#yaml-style-meta-data) for more information on how the meta-data block is used.
104
83
 
105
84
  ### Multiple Aliases
@@ -134,16 +113,23 @@ plugins:
134
113
  - alias:
135
114
  verbose: true
136
115
  use_anchor_titles: true
116
+ use_page_icon: true
137
117
  ```
138
118
 
139
119
  ### `verbose`
140
120
 
141
- You may use the optional `verbose` option to print more information about which aliases were used and defined during the build process. The default value is `false`.
121
+ You may use the optional `verbose` option to print more information about which aliases were used and defined during the build process. A tab-delimited file named `aliases.log` will also be defined at the project root, containing a list of every alias defined by the wiki.
122
+
123
+ The default value is `false` and should only be enabled when debugging issue with the plugin.
142
124
 
143
125
  ### `use_anchor_titles`
144
126
 
145
127
  Setting this flag to true causes the plugin to replace an alias containing an anchor (`[[my-page#sub-heading]]`) with the text of the header that defined it. You can still override the title of the link as usual.
146
128
 
129
+ ### `use_page_icons`
130
+
131
+ Setting this flag to true will include the [page's icon](https://squidfunk.github.io/mkdocs-material/reference/?h=page+icon#setting-the-page-icon) in the alias substitution if it's set for a given page.
132
+
147
133
  ## Troubleshooting
148
134
 
149
135
  ### The link text looks like a path or URL
@@ -168,6 +154,13 @@ Aliases *must* be unique. Ensure that you're not redefining the same alias for a
168
154
 
169
155
  ## Local Development
170
156
 
157
+ Upgrade pip and install the dependencies:
158
+
159
+ ```zsh
160
+ python -m pip install --upgrade pip
161
+ pip install mkdocs pytest pylint markdown setuptools
162
+ ```
163
+
171
164
  Installing a local copy of the plugin:
172
165
 
173
166
  ```zsh
@@ -188,12 +181,33 @@ pylint $(git ls-files '*.py') && pytest -vv
188
181
 
189
182
  ## Changelog
190
183
 
184
+ ## 0.9.0
185
+
186
+ 2025-02-21
187
+
188
+ **Features and Bug Fixes:**
189
+
190
+ - Added the ability to use alias style links to anchors withing the current page, e.g.: `[[#my-anchor]]`.
191
+ - Added support for page icons in link aliases, thank you @joapuiib for your [contribution](https://github.com/EddyLuten/mkdocs-alias-plugin/pull/15)!
192
+ - Added support for using the key `alias` and/or `aliases` for defining page aliases in meta sections.
193
+ - Changed verbose mode to now also generates a tab-delimited log file containing each alias in the wiki.
194
+
195
+ ## 0.8.1
196
+
197
+ 2024-04-08
198
+
199
+ **Bug Fix:** fixes a bug where annotations would break older versions of Python 3. Bug report: [#9](https://github.com/EddyLuten/mkdocs-alias-plugin/issues/9).
200
+
191
201
  ## 0.8.0
192
202
 
203
+ 2024-04-06
204
+
193
205
  This release adds functionality to replace the titles of aliases containing anchors with the text of the heading that defines them. Enable this feature by setting the plugin option `use_anchor_titles` to true. Feature request: [#8](https://github.com/EddyLuten/mkdocs-alias-plugin/issues/8).
194
206
 
195
207
  ### 0.7.1
196
208
 
209
+ 2024-04-07
210
+
197
211
  **Bug Fix:** fixes a bug where any alias with the word "text" would break the plugin due to faulty logic. Bug report: [#7](https://github.com/EddyLuten/mkdocs-alias-plugin/issues/7).
198
212
 
199
213
  ### 0.7.0
@@ -2,6 +2,7 @@
2
2
 
3
3
  An MkDocs plugin allowing links to your pages using a custom alias.
4
4
  """
5
+ from __future__ import annotations
5
6
 
6
7
  import logging
7
8
  import re
@@ -49,21 +50,24 @@ def find_anchor_by_id(anchors: list[MarkdownAnchor], anchor_id: str) -> Markdown
49
50
  return None
50
51
 
51
52
 
52
- def get_page_title(page_src: str, meta_data: dict):
53
+ def get_page_title(page_src: str, meta_data: dict, include_icon: bool = False):
53
54
  """Returns the title of the page. The title in the meta data section
54
55
  will take precedence over the H1 markdown title if both are provided."""
55
- return (
56
- meta_data['title']
57
- if 'title' in meta_data and isinstance(meta_data['title'], str)
58
- else get_markdown_title(page_src)
59
- )
56
+ if 'title' in meta_data and isinstance(meta_data['title'], str):
57
+ title = meta_data['title']
58
+ if include_icon and 'icon' in meta_data and isinstance(meta_data['icon'], str):
59
+ icon = ':' + meta_data['icon'].replace('/', '-') + ':'
60
+ title = f'{icon} {title}'
61
+ else:
62
+ title = get_markdown_title(page_src)
63
+ return title
60
64
 
61
65
 
62
- def get_alias_names(meta_data: dict):
66
+ def get_alias_names(meta_data: dict, meta_key: str = 'alias') -> list[str] | None:
63
67
  """Returns the list of configured alias names."""
64
- if len(meta_data) <= 0 or 'alias' not in meta_data:
68
+ if len(meta_data) <= 0 or meta_key not in meta_data:
65
69
  return None
66
- aliases = meta_data['alias']
70
+ aliases = meta_data[meta_key]
67
71
  if isinstance(aliases, list):
68
72
  # If the alias meta data is a list, ensure that they're strings
69
73
  return list(filter(lambda value: isinstance(value, str), aliases))
@@ -90,13 +94,27 @@ def replace_tag(
90
94
  if match.group(2) is not None:
91
95
  tag_bits = str(match.group(2)).split('#')
92
96
  alias = aliases.get(tag_bits[0])
97
+
98
+ # if the alias is not found, log a warning and return the input string
99
+ # unless the alias is an anchor tag, then try to find the anchor tag
100
+ # and replace it with the anchor's title
93
101
  if alias is None:
94
- log.warning(
95
- "Alias '%s' not found in '%s'",
96
- match.group(2),
97
- page_file.src_path
98
- )
99
- return match.group(0) # return the input string
102
+ if len(tag_bits) < 2:
103
+ log.warning(
104
+ "Alias '%s' not found in '%s'",
105
+ match.group(2),
106
+ page_file.src_path
107
+ )
108
+ return match.group(0) # return the input string
109
+ anchor = tag_bits[1]
110
+ matched = match.group(2)
111
+ # using the [[#anchor]] syntax to link within the current page:
112
+ if str(matched).startswith('#'):
113
+ anchors = get_markdown_toc(page_file.content_string)
114
+ anchor_tag = find_anchor_by_id(anchors, anchor)
115
+ if anchor_tag is not None:
116
+ log.info(f"treating {matched} like an anchor to {anchor_tag['name']}")
117
+ return f"[{anchor_tag['name']}](#{anchor})"
100
118
 
101
119
  text = None
102
120
  anchor = tag_bits[1] if len(tag_bits) > 1 else None
@@ -139,6 +157,7 @@ class AliasPlugin(BasePlugin):
139
157
  config_scheme = (
140
158
  ('verbose', config_options.Type(bool, default=False)),
141
159
  ('use_anchor_titles', config_options.Type(bool, default=False)),
160
+ ('use_page_icon', config_options.Type(bool, default=False)),
142
161
  )
143
162
  aliases = {}
144
163
  log = logging.getLogger(f'mkdocs.plugins.{__name__}')
@@ -157,7 +176,7 @@ class AliasPlugin(BasePlugin):
157
176
  self.log.info("Defined %s alias(es).", len(self.aliases))
158
177
  self.aliases.clear()
159
178
 
160
- def on_page_markdown(self, markdown: str, *, page: Page, **_):
179
+ def on_page_markdown(self, markdown: str, /, *, page: Page, **_):
161
180
  """Replaces any alias tags on the page with markdown links."""
162
181
  self.current_page = page
163
182
  return re.sub(
@@ -172,52 +191,68 @@ class AliasPlugin(BasePlugin):
172
191
  markdown
173
192
  )
174
193
 
175
- def on_files(self, files: Files, **_):
194
+ def on_files(self, files: Files, /, **_):
176
195
  """When MkDocs loads its files, extract aliases from any Markdown files
177
196
  that were found.
178
197
  """
179
198
  for file in filter(lambda f: f.is_documentation_page(), files):
180
199
  with open(file.abs_src_path, encoding='utf-8-sig', errors='strict') as handle:
181
- source, meta_data = meta.get_data(handle.read())
182
- alias_names = get_alias_names(meta_data)
183
- if alias_names is None or len(alias_names) < 1:
184
- continue
200
+ self.process_file(file, handle)
201
+ # write the aliases to the aliases log file if the verbose option is set
202
+ if self.config['verbose']:
203
+ with open('aliases.log', 'w', encoding='utf-8') as log_file:
204
+ log_file.write("alias\ttitle\turl\n")
205
+ for alias in self.aliases.values():
206
+ log_file.write(
207
+ f"{alias['alias']}\t{alias['text']}\t{alias['url']}\n"
208
+ )
185
209
 
186
- # If the use_anchor_titles config option is set, parse the markdown
187
- # and get the table of contents for the page
188
- anchors: list[MarkdownAnchor] = []
189
- if self.config['use_anchor_titles']:
190
- anchors = get_markdown_toc(source)
210
+ def process_file(self, file, handle):
211
+ """Extract aliases from the given file and add them to the aliases"""
212
+ source, meta_data = meta.get_data(handle.read())
213
+ for section in ['alias', 'aliases']:
214
+ alias_names = get_alias_names(meta_data, section)
215
+ if alias_names is None or len(alias_names) < 1:
216
+ continue
191
217
 
192
- if len(alias_names) > 1:
193
- self.log.info(
194
- '%s defines %d aliases:', file.url, len(alias_names)
195
- )
196
- for alias in alias_names:
197
- existing = self.aliases.get(alias)
198
- if existing is not None:
199
- self.log.warning(
200
- "%s: alias %s already defined in %s, skipping.",
201
- file.src_uri,
202
- alias,
203
- existing['url']
204
- )
205
- continue
206
-
207
- new_alias = {
208
- 'alias': alias,
209
- 'text': (
210
- meta_data['alias']['text']
211
- # if meta_data['alias'] is a dictionary and 'text' is a key
212
- if isinstance(meta_data['alias'], dict) and 'text' in meta_data['alias']
213
- else get_page_title(source, meta_data)
214
- ),
215
- 'url': file.src_uri,
216
- 'anchors': anchors,
217
- }
218
- self.log.info(
219
- "Alias %s to %s",
218
+ # If the use_anchor_titles config option is set, parse the markdown
219
+ # and get the table of contents for the page
220
+ anchors: list[MarkdownAnchor] = []
221
+ if self.config['use_anchor_titles']:
222
+ anchors = get_markdown_toc(source)
223
+
224
+ if len(alias_names) > 1:
225
+ self.log.info(
226
+ '%s defines %d aliases:', file.url, len(alias_names)
227
+ )
228
+ for alias in alias_names:
229
+ existing = self.aliases.get(alias)
230
+ if existing is not None:
231
+ self.log.warning(
232
+ "%s: alias %s already defined in %s, skipping.",
233
+ file.src_uri,
220
234
  alias,
221
- new_alias['url']
235
+ existing['url']
222
236
  )
223
- self.aliases[alias] = new_alias
237
+ continue
238
+
239
+ new_alias = {
240
+ 'alias': alias,
241
+ 'text': (
242
+ meta_data[section]['text']
243
+ # if meta_data['alias'] is a dictionary and 'text' is a key
244
+ if (
245
+ isinstance(meta_data[section], dict) and
246
+ 'text' in meta_data[section]
247
+ )
248
+ else get_page_title(source, meta_data, self.config['use_page_icon'])
249
+ ),
250
+ 'url': file.src_uri,
251
+ 'anchors': anchors,
252
+ }
253
+ self.log.info(
254
+ "Alias %s to %s",
255
+ alias,
256
+ new_alias['url']
257
+ )
258
+ self.aliases[alias] = new_alias
@@ -1,6 +1,40 @@
1
+ Metadata-Version: 2.2
2
+ Name: mkdocs-alias-plugin
3
+ Version: 0.8.2
4
+ Summary: An MkDocs plugin allowing links to your pages using a custom alias
5
+ Home-page: https://github.com/eddyluten/mkdocs-alias-plugin
6
+ Author: Eddy Luten
7
+ Author-email: eddyluten@gmail.com
8
+ License: MIT
9
+ Keywords: mkdocs python markdown alias link wiki
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
+ Classifier: Topic :: Documentation
15
+ Classifier: Topic :: Text Processing
16
+ Classifier: Topic :: Text Processing :: Markup
17
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
18
+ Requires-Python: >=3.0
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE.md
21
+ Requires-Dist: mkdocs
22
+ Requires-Dist: markdown
23
+ Dynamic: author
24
+ Dynamic: author-email
25
+ Dynamic: classifier
26
+ Dynamic: description
27
+ Dynamic: description-content-type
28
+ Dynamic: home-page
29
+ Dynamic: keywords
30
+ Dynamic: license
31
+ Dynamic: requires-dist
32
+ Dynamic: requires-python
33
+ Dynamic: summary
34
+
1
35
  # mkdocs-alias-plugin
2
36
 
3
- [![PyPI version](https://badge.fury.io/py/mkdocs-alias-plugin.svg)](https://pypi.org/project/mkdocs-alias-plugin/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ![example workflow](https://github.com/eddyluten/mkdocs-alias-plugin/actions/workflows/pylint.yml/badge.svg) [![Downloads](https://pepy.tech/badge/mkdocs-alias-plugin)](https://pepy.tech/project/mkdocs-alias-plugin) ![](https://github.com/eddyluten/mkdocs-alias-plugin/workflows/mkdocs-alias-plugin%20Tests/badge.svg)
37
+ [![PyPI version](https://badge.fury.io/py/mkdocs-alias-plugin.svg)](https://pypi.org/project/mkdocs-alias-plugin/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Downloads](https://pepy.tech/badge/mkdocs-alias-plugin)](https://pepy.tech/project/mkdocs-alias-plugin) [![CI](https://github.com/eddyluten/mkdocs-alias-plugin/workflows/mkdocs-alias-plugin%20CI/badge.svg)](https://github.com/EddyLuten/mkdocs-alias-plugin/actions/workflows/ci.yml)
4
38
 
5
39
  The `mkdocs-alias-plugin` MkDocs plugin allows links to your pages using a custom alias such as `[[my-alias]]` or `[[my-alias|My Title]]`.
6
40
 
@@ -77,6 +111,8 @@ The song references [[wuthering-heights#references|Wuthering Heights]].
77
111
 
78
112
  As of version 0.8.0, you can enable the plugin option `use_anchor_titles` to replace anchor links with the text of the page heading that defined it. This behavior is opt-in to preserve backward compatibility.
79
113
 
114
+ As of version 0.9.0, you may also use `aliases` in addition to (or in place of) the `alias` key in the meta section of your pages. This is to provide some similarity to other Markdown based software that supports aliases, such as Obsidian.
115
+
80
116
  Please refer to the [MkDocs documentation](https://www.mkdocs.org/user-guide/writing-your-docs/#yaml-style-meta-data) for more information on how the meta-data block is used.
81
117
 
82
118
  ### Multiple Aliases
@@ -111,16 +147,23 @@ plugins:
111
147
  - alias:
112
148
  verbose: true
113
149
  use_anchor_titles: true
150
+ use_page_icon: true
114
151
  ```
115
152
 
116
153
  ### `verbose`
117
154
 
118
- You may use the optional `verbose` option to print more information about which aliases were used and defined during the build process. The default value is `false`.
155
+ You may use the optional `verbose` option to print more information about which aliases were used and defined during the build process. A tab-delimited file named `aliases.log` will also be defined at the project root, containing a list of every alias defined by the wiki.
156
+
157
+ The default value is `false` and should only be enabled when debugging issue with the plugin.
119
158
 
120
159
  ### `use_anchor_titles`
121
160
 
122
161
  Setting this flag to true causes the plugin to replace an alias containing an anchor (`[[my-page#sub-heading]]`) with the text of the header that defined it. You can still override the title of the link as usual.
123
162
 
163
+ ### `use_page_icons`
164
+
165
+ Setting this flag to true will include the [page's icon](https://squidfunk.github.io/mkdocs-material/reference/?h=page+icon#setting-the-page-icon) in the alias substitution if it's set for a given page.
166
+
124
167
  ## Troubleshooting
125
168
 
126
169
  ### The link text looks like a path or URL
@@ -145,6 +188,13 @@ Aliases *must* be unique. Ensure that you're not redefining the same alias for a
145
188
 
146
189
  ## Local Development
147
190
 
191
+ Upgrade pip and install the dependencies:
192
+
193
+ ```zsh
194
+ python -m pip install --upgrade pip
195
+ pip install mkdocs pytest pylint markdown setuptools
196
+ ```
197
+
148
198
  Installing a local copy of the plugin:
149
199
 
150
200
  ```zsh
@@ -165,12 +215,33 @@ pylint $(git ls-files '*.py') && pytest -vv
165
215
 
166
216
  ## Changelog
167
217
 
218
+ ## 0.9.0
219
+
220
+ 2025-02-21
221
+
222
+ **Features and Bug Fixes:**
223
+
224
+ - Added the ability to use alias style links to anchors withing the current page, e.g.: `[[#my-anchor]]`.
225
+ - Added support for page icons in link aliases, thank you @joapuiib for your [contribution](https://github.com/EddyLuten/mkdocs-alias-plugin/pull/15)!
226
+ - Added support for using the key `alias` and/or `aliases` for defining page aliases in meta sections.
227
+ - Changed verbose mode to now also generates a tab-delimited log file containing each alias in the wiki.
228
+
229
+ ## 0.8.1
230
+
231
+ 2024-04-08
232
+
233
+ **Bug Fix:** fixes a bug where annotations would break older versions of Python 3. Bug report: [#9](https://github.com/EddyLuten/mkdocs-alias-plugin/issues/9).
234
+
168
235
  ## 0.8.0
169
236
 
237
+ 2024-04-06
238
+
170
239
  This release adds functionality to replace the titles of aliases containing anchors with the text of the heading that defines them. Enable this feature by setting the plugin option `use_anchor_titles` to true. Feature request: [#8](https://github.com/EddyLuten/mkdocs-alias-plugin/issues/8).
171
240
 
172
241
  ### 0.7.1
173
242
 
243
+ 2024-04-07
244
+
174
245
  **Bug Fix:** fixes a bug where any alias with the word "text" would break the plugin due to faulty logic. Bug report: [#7](https://github.com/EddyLuten/mkdocs-alias-plugin/issues/7).
175
246
 
176
247
  ### 0.7.0
@@ -7,7 +7,7 @@ long_description = (this_directory / 'README.md').read_text()
7
7
 
8
8
  setup(
9
9
  name='mkdocs-alias-plugin',
10
- version='0.8.0',
10
+ version='0.8.2',
11
11
  description=
12
12
  'An MkDocs plugin allowing links to your pages using a custom alias',
13
13
  long_description=long_description,