Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for hash fragment redirect targets #42

Merged
merged 5 commits into from
Aug 21, 2022

Conversation

wwarriner
Copy link
Contributor

Adds support for hash fragment redirect targets.

This will allow e.g. old.md: new.md#section to work as expected.

I added a helper function to split the hash fragment off the rest of the path. Whenever the hash fragment gets in the way of path manipulation logic, it gets detached and/or reattached, as appropriate.

To validate I added duplicate test cases with hash fragments, though there are no tests for on_post_build(). I verified that with a mkdocs project, but can't readily share that verification.

Fixes #16

mkdocs_redirects/plugin.py Outdated Show resolved Hide resolved
mkdocs_redirects/plugin.py Outdated Show resolved Hide resolved
mkdocs_redirects/plugin.py Outdated Show resolved Hide resolved
mkdocs_redirects/plugin.py Outdated Show resolved Hide resolved
@wwarriner
Copy link
Contributor Author

I think this is done. I am unsure how to address the concern over silent drop of the second return value from the helper function on line 133 on plugin.py. In my experience this hasn't caused any issues, but I defer to your expertise.

@oprypin
Copy link
Contributor

oprypin commented Aug 21, 2022

Thanks

@oprypin oprypin merged commit 52f95e0 into mkdocs:master Aug 21, 2022
@oprypin
Copy link
Contributor

oprypin commented Aug 22, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for hash fragments
2 participants