zachhannum / mkdocs-autolinks-plugin

An MkDocs plugin that automagically generates relative links between markdown pages
https://pypi.org/project/mkdocs-autolinks-plugin/
MIT License
80 stars 31 forks source link

Fix for issue #4 #5

Closed bgwr closed 4 years ago

bgwr commented 4 years ago

Thanks @midnightprioriem for this plugin that helped with my documentation!

I was running into the same issue as @chrieke, and the fix seemed trivial, so I made this fork and tested locally... all runs as expected.

With this PR, you can add the hash-links at the end of a filename and have them added back in after the relative link is resolved from, the filesystem crawl.

The regex now generates the following match groups for Link Text: 0: Whole link markup - [Link Text](filename.md#anchor-link) 1: Link text part without brackets - Link Text 2: Full URL without parentheses including hash anchor if present - filename.md#anchor-link 3: Filename without any hash anchor if present - filename.md 4: File extension - .md 5: Hash anchor with hash mark - #anchor-link

Because the match group numbers changed, I had to change references in some other lines.

Thanks again!

zachhannum commented 4 years ago

Looks and works great, thanks!