orbikm / mkdocs-ezlinks-plugin

Plugin for mkdocs which enables easier linking between pages
MIT License
34 stars 17 forks source link

Fix functional relative links, and add auto-disambiguation #21

Closed orbikm closed 3 years ago

orbikm commented 3 years ago

Implement auto-disambiguation and bugfix

* This fixes a bug in the previous search strategy that missed
  allowing for local relative links (something like index.md
  referring to about.md in the same subdirectory).

* It also adds a bit further auto-disambiguation. By this,
  I mean it will attempt to find the _closest_ match in proximity
  (with respect to the folder hierarchy). For instance,
  if this is the layout:

  ```
  + guide/
    + test.md
    + getting_started/
        + index.md
  + tutorials/
    - test.md
    + getting_started/
       + index.md
    + more_advanced/
       + index.md
  ```
  If you placed a link inside `guide/getting_started/index.md`
  such as `[Test](test)`, the resulting link has ambiguity, but
  in the default case, the `guide/test.md` file is _closer_ than
  the `tutorials/test.md`, therefore, it will select that file.

  You can still further disambiguate the link if desired, but
  this provides a bit more sane defaults.