oprypin / mkdocs-literate-nav

MkDocs plugin to specify the navigation in Markdown instead of YAML
https://oprypin.github.io/mkdocs-literate-nav
MIT License
73 stars 8 forks source link

Funny/weird: using literate-nav strips one slash from https:// in nav links #8

Closed pawamoy closed 2 years ago

pawamoy commented 2 years ago

See https://github.com/mkdocstrings/mkdocstrings/issues/337

It seems to happen only when the literate-nav plugin is activated, even when there's no SUMMARY.md file in the docs.

Here's the nav:

nav:
- Home:
  - Overview: index.md
  - Changelog: changelog.md
  - Credits: credits.md
  - License: license.md
- Usage:
  - usage.md
  - Theming: theming.md
  - Handlers:
    - handlers/overview.md
    - Python: handlers/python.md
    - Crystal: https://mkdocstrings.github.io/crystal/
  - Troubleshooting: troubleshooting.md
# defer to gen-files + literate-nav
- Code Reference: reference/
- Development:
  - Contributing: contributing.md
  - Code of Conduct: code_of_conduct.md
  - Coverage report: coverage.md
- Author's website: https://pawamoy.github.io/

Looking at the built site, the link appear as https:/pawamoy.github.io/ and https:/mkdocstrings.github.io/crystal/ (note the single slash in https:/). It's a bummer because somehow my browser (firefox) fixes it locally, but not when accessing the pages on github.io. Online, the browser ends up directing to https://mkdocstrings.github.io/pawamoy.github.io and https://mkdocstrings.github.io/mkdocstrings.github.io/crystal, which do not exist of course.

I'll try to read the code and guess what's happening here :slightly_smiling_face:

pawamoy commented 2 years ago

OK, it seems that the guilty one is posixpath.normpath: https://github.com/oprypin/mkdocs-literate-nav/blob/95d90bc581cb04db48baef6ef23bfb3d46b86d3e/mkdocs_literate_nav/parser.py#L107 It's removing a slash from https:// :hear_no_evil: Looks like normal behavior for this function, so it should probably not be used on full, actual URIs. Not sure how to circumvent that :confused:

oprypin commented 2 years ago

Oops. Thanks for the report!

oprypin commented 2 years ago

And the fix made it into a release now.

pawamoy commented 2 years ago

Nice, thanks a lot!