Skip to content

Commit

Permalink
Implemented POSIX path to support Mkdocs v1.4.0 in Windows (#31)
Browse files Browse the repository at this point in the history
* Implemented POSIX path to support Mkdocs v1.4.0 and above under Windows. Fixed a broken link in README.md

* Update plugin.py
  • Loading branch information
arterm-sedov authored Feb 27, 2023
1 parent ad131a3 commit bc7ec40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ plugins:
> **Note:** If you have no `plugins` entry in your config file yet, you'll likely also want to add the `search` plugin. MkDocs enables it by default if there is no `plugins` entry set, but now you have to enable it explicitly.

More information about plugins in the [MkDocs documentation][mkdocs-plugins].
More information about plugins in the [MkDocs documentation](https://www.mkdocs.org/dev-guide/plugins/).


## Usage
Expand Down
3 changes: 2 additions & 1 deletion mkdocs_autolinks_plugin/plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os
import pathlib
import re
from urllib.parse import quote
import logging
Expand Down Expand Up @@ -60,7 +61,7 @@ def __call__(self, match):
)

abs_link_path = abs_link_paths[0]
rel_link_path = quote(os.path.relpath(abs_link_path, abs_linker_dir))
rel_link_path = quote(pathlib.PurePath(os.path.relpath(abs_link_path, abs_linker_dir)).as_posix())

# Construct the return link by replacing the filename with the relative path to the file
return match.group(0).replace(match.group(3), rel_link_path)
Expand Down

0 comments on commit bc7ec40

Please sign in to comment.