mkdocs-ezlinked-plugin


Namemkdocs-ezlinked-plugin JSON
Version 0.3.3 PyPI version JSON
download
home_pagehttps://github.com/Mara-Li/mkdocs-ezlinks-plugin
SummaryA mkdocs plugin that makes linking to other documents easy.
upload_time2022-12-08 01:01:19
maintainer
docs_urlNone
authorMara-Li
requires_python>=3.6
licenseMIT
keywords mkdocs wikilinks ezlinks obsidian roam
VCS
bugtrack_url
requirements mkdocs dataclasses pygtrie
Travis-CI No Travis.
coveralls test coverage No coveralls.
            *Fork*  
To install this fork :   
`pip install mkdocs-ezlinked-plugin`  

# mkdocs-ezlinks-plugin

![](logo.png)

Plugin for mkdocs which enables easier linking between pages.

This plugin was written in order to provide an up-to-date and
feature complete plugin for easily referencing documents
with a variety of features:

* Optimized file name lookup
* Code Block Preservation
* File name linking (e.g. `[Text](file#anchor "title")`)
* Absolute paths (e.g. `[Text](/link/to/file.md)`)
* WikiLinks support (e.g. `[[Link#anchor|Link Title]]`)
* Reference Link support (e.g. `[foo]: bar/ "Foo Title"`)

# Install
```
pip install mkdocs-ezlinks-plugin
```

Edit your mkdocs configuration file to enable the plugin:
```
plugins:
  - search
  - ezlinks
```
> **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.

# Release Log

## Release 0.1.14
This is a bugfix release.

Issues addressed:
  * GH issue #35, `Links between deeply nested subfolders fails.`
    Dev @Mara-Li reported an issue with wikilinks between deeply nested subfolders failing due to an incorrectly
    rendered relative link to the file.

  * An unreported Windows usage issue
    It's possible this bug existed for quite some time. Basically, on Windows, there was disagreement between the
    path separators used at different points in the file mapping and searching process. This unifies it to store
    and search for paths only with the `/` delimiter instead of the OS defined separator.


## Release 0.1.13
Adds support for Reference Link parsing. This is to support certain Foam editors, which generate [Reference Links](https://spec.commonmark.org/0.29/#reference-link).

Issues Addressed:
  * GH Issue #31, `Add support for reference link definitions`. Allows compatibility with certain Foam editors which generate Reference Links.

## Release 0.1.12
This is a bugfix release.

Issues addressed:
  * GH issue #25, `Absolute links not using http:// or https:// are treated as relative`.
    Dev @robbcrg (thanks!) reported that links with protocol schemes other than those two should also be treated as
    absolute links. The regex will exclude any link from a conformant protocol scheme from being converted using EzLinks.

  * GH Issue #27, `Dictionary file cache is not being leveraged`.
    An inverted comparison led to the fast file cache lookup never really being exercised. Now, if a filename is unique, it will find it in the fast file cache first, saving a more expensive full trie lookup.

## Release 0.1.11
This is a bugfix release. The prior release switched from a dictionary lookup to a prefix trie lookup strategy, which allowed for better disambiguation between links, but is more expensive. The bug was that, even if a link was direct, it would trigger a full trie search. Now, direct links
are checked and returned directly if the file exists.

Additionally, a slight performance improvement was made where, in the case that a filename is unique to the entire site, it will rely on a fast dictionary lookup instead of a trie lookup.

# Configuration Options
```
plugins:
    - search
    - ezlinks:
        warn_ambiguities: {true|false}
        wikilinks: {true|false}
        reference_links: {true|false}
```
## warn_ambiguities
Determines whether to warn when an abmiguous link is encountered. An ambiguous link is one that would have more than one possible targets. For example, if you had the following document setup:

```
+ folder1/
  +-- index.md
+ folder2/
  +-- index.md
```

If you had any links that targeted `index.md`, EzLinks is not able to determine _which_ of the instances of `index.md` to target, thus it is ambiguous.

### Disambiguating links
By default, EzLinks will attempt to resolve the ambiguity automatically. It does this by searching for the file closest to the file that is linking (with respect to the folder hierarchy).

```
+ 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.

In the circumstance above, it would be possible to disambiguate _which_ `test.md` by including the containing folder, e.g. `guide/test.md` or `tutorials/test.md`. Note: This also works in conjunction with extension-less targets, e.g. `guide/test` and `tutorials/test`.

This disambiguation can continue with as many parent directories are specified, for instance `folder1/subfolder1/subfolder2/test.md`, specifying as many path components as necessary to fully disambiguate the links.

This method of disambiguation is supported by each of the supported link formats (MD links, wiki/roamlinks). For instance, you can use `[[folder1/index|Link Title]]` and `[[folder2/index.md]]`.

## wikilinks
Determines whether to scan for wikilinks or not (See [WikiLink Support](#wikilink-support)).
> **NOTE**  
>  This plugin feature does not function well when the 'wikilinks' markdown extension is enabled. This plugin's functionality should replace the need for enabling said extension.

## reference_links
Determins whether to scan for Reference Links or not (See [Reference Links](https://spec.commonmark.org/0.29/#reference-link), e.g. `[foo]: /bar "Foo Bar"`)

# Features
## Filename Links
Given a layout such as
```
- index.md
- folder/
  +-- filename.md
  +-- image.png
```

The following links will result in the following translations,

|Link|Translation|
|----|-----------|
| `[Link Text](filename)` | `[Link Text](folder/filename.md)`|
| `[Link Text](filename#Anchor)` | `[Link Text](folder/filename.md#Anchor)`|
| `[Link Text](filename.md)` | `[Link Text](folder/filename.md)`|
| `[Link Text](filename.md#Anchor)` | `[Link Text](folder/filename.md#Anchor)` |
| `![Image Alt Text](image)` | `![Image Alt Text](folder/image.png)` |
| `![Image Alt Text](image.png)` | `![Image Alt Text](folder/image.png)` |
| `![Image Alt Test](image "Image Title")` | `![Image Alt Text](folder/image.png "Image Title")` |


## Absolute Links
Given a layout such as
```
- static/
  +-- image.png
- folder/
  +-- document.md
- index.md
```
Given that we are entering the links into the `folder/document.md` file,

|Link|Translation|
|----|-----------|
| `![Link Text](/static/image.png)` | `![Link Text](../static/image.png)` |

# WikiLink Support
Given a layout such as
```
- folder1/
  +-- main.md
- folder2/
  +-- page-name.md
- images/
  +-- puppy.png
```
and these links are entered in `folder1/main.md`, this is how wikilinks will be translated

|Link|Translation|
|----|-----------|
| `[[Page Name]]` | `[Page Name](../folder2/page-name.md)` |
| `![[Puppy]]` | `![Puppy](../images/puppy.png)` | `[[Page Name#Section Heading]]` | `[Page Name](../relative/path/to/page-name.md#section-heading)` |
| `[[Page Name\|Link Text]]` | `[Link Text](../folder2/page-name.md)` |
| `[[Page Name#Section Heading\|Link Text]]` | `[Link Text](../folder2/page-name.md#section-heading)` |

# Attribution
This work is highly inspired from the following plugins:
  - [mkdocs-autolinks-plugin](https://github.com/midnightprioriem/mkdocs-autolinks-plugin/)
  - [mkdocs-roamlinks-plugin](https://github.com/Jackiexiao/mkdocs-roamlinks-plugin)
  - [mkdocs-abs-rel-plugin](https://github.com/sander76/mkdocs-abs-rel-plugin)

  I have combined some the features of these plugins, fixed several existing bugs, and am adding features in order to
  provide a cohesive, up-to-date, and maintained solution for the mkdocs community.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Mara-Li/mkdocs-ezlinks-plugin",
    "name": "mkdocs-ezlinked-plugin",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "mkdocs,wikilinks,ezlinks,obsidian,roam",
    "author": "Mara-Li",
    "author_email": "Mara-Li@outlook.fr",
    "download_url": "https://files.pythonhosted.org/packages/1d/33/ab9ed623f18cbff71c3894b1d7ac2b02c6f359614bfdff18431884f14e12/mkdocs-ezlinked-plugin-0.3.3.tar.gz",
    "platform": null,
    "description": "*Fork*  \nTo install this fork :   \n`pip install mkdocs-ezlinked-plugin`  \n\n# mkdocs-ezlinks-plugin\n\n![](logo.png)\n\nPlugin for mkdocs which enables easier linking between pages.\n\nThis plugin was written in order to provide an up-to-date and\nfeature complete plugin for easily referencing documents\nwith a variety of features:\n\n* Optimized file name lookup\n* Code Block Preservation\n* File name linking (e.g. `[Text](file#anchor \"title\")`)\n* Absolute paths (e.g. `[Text](/link/to/file.md)`)\n* WikiLinks support (e.g. `[[Link#anchor|Link Title]]`)\n* Reference Link support (e.g. `[foo]: bar/ \"Foo Title\"`)\n\n# Install\n```\npip install mkdocs-ezlinks-plugin\n```\n\nEdit your mkdocs configuration file to enable the plugin:\n```\nplugins:\n  - search\n  - ezlinks\n```\n> **NOTE**  \n>   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.\n\n# Release Log\n\n## Release 0.1.14\nThis is a bugfix release.\n\nIssues addressed:\n  * GH issue #35, `Links between deeply nested subfolders fails.`\n    Dev @Mara-Li reported an issue with wikilinks between deeply nested subfolders failing due to an incorrectly\n    rendered relative link to the file.\n\n  * An unreported Windows usage issue\n    It's possible this bug existed for quite some time. Basically, on Windows, there was disagreement between the\n    path separators used at different points in the file mapping and searching process. This unifies it to store\n    and search for paths only with the `/` delimiter instead of the OS defined separator.\n\n\n## Release 0.1.13\nAdds support for Reference Link parsing. This is to support certain Foam editors, which generate [Reference Links](https://spec.commonmark.org/0.29/#reference-link).\n\nIssues Addressed:\n  * GH Issue #31, `Add support for reference link definitions`. Allows compatibility with certain Foam editors which generate Reference Links.\n\n## Release 0.1.12\nThis is a bugfix release.\n\nIssues addressed:\n  * GH issue #25, `Absolute links not using http:// or https:// are treated as relative`.\n    Dev @robbcrg (thanks!) reported that links with protocol schemes other than those two should also be treated as\n    absolute links. The regex will exclude any link from a conformant protocol scheme from being converted using EzLinks.\n\n  * GH Issue #27, `Dictionary file cache is not being leveraged`.\n    An inverted comparison led to the fast file cache lookup never really being exercised. Now, if a filename is unique, it will find it in the fast file cache first, saving a more expensive full trie lookup.\n\n## Release 0.1.11\nThis is a bugfix release. The prior release switched from a dictionary lookup to a prefix trie lookup strategy, which allowed for better disambiguation between links, but is more expensive. The bug was that, even if a link was direct, it would trigger a full trie search. Now, direct links\nare checked and returned directly if the file exists.\n\nAdditionally, a slight performance improvement was made where, in the case that a filename is unique to the entire site, it will rely on a fast dictionary lookup instead of a trie lookup.\n\n# Configuration Options\n```\nplugins:\n    - search\n    - ezlinks:\n        warn_ambiguities: {true|false}\n        wikilinks: {true|false}\n        reference_links: {true|false}\n```\n## warn_ambiguities\nDetermines whether to warn when an abmiguous link is encountered. An ambiguous link is one that would have more than one possible targets. For example, if you had the following document setup:\n\n```\n+ folder1/\n  +-- index.md\n+ folder2/\n  +-- index.md\n```\n\nIf you had any links that targeted `index.md`, EzLinks is not able to determine _which_ of the instances of `index.md` to target, thus it is ambiguous.\n\n### Disambiguating links\nBy default, EzLinks will attempt to resolve the ambiguity automatically. It does this by searching for the file closest to the file that is linking (with respect to the folder hierarchy).\n\n```\n+ guide/\n  + test.md\n  + getting_started/\n      + index.md\n+ tutorials/\n  - test.md\n  + getting_started/\n      + index.md\n  + more_advanced/\n      + index.md\n```\nIf 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.\n\nIn the circumstance above, it would be possible to disambiguate _which_ `test.md` by including the containing folder, e.g. `guide/test.md` or `tutorials/test.md`. Note: This also works in conjunction with extension-less targets, e.g. `guide/test` and `tutorials/test`.\n\nThis disambiguation can continue with as many parent directories are specified, for instance `folder1/subfolder1/subfolder2/test.md`, specifying as many path components as necessary to fully disambiguate the links.\n\nThis method of disambiguation is supported by each of the supported link formats (MD links, wiki/roamlinks). For instance, you can use `[[folder1/index|Link Title]]` and `[[folder2/index.md]]`.\n\n## wikilinks\nDetermines whether to scan for wikilinks or not (See [WikiLink Support](#wikilink-support)).\n> **NOTE**  \n>  This plugin feature does not function well when the 'wikilinks' markdown extension is enabled. This plugin's functionality should replace the need for enabling said extension.\n\n## reference_links\nDetermins whether to scan for Reference Links or not (See [Reference Links](https://spec.commonmark.org/0.29/#reference-link), e.g. `[foo]: /bar \"Foo Bar\"`)\n\n# Features\n## Filename Links\nGiven a layout such as\n```\n- index.md\n- folder/\n  +-- filename.md\n  +-- image.png\n```\n\nThe following links will result in the following translations,\n\n|Link|Translation|\n|----|-----------|\n| `[Link Text](filename)` | `[Link Text](folder/filename.md)`|\n| `[Link Text](filename#Anchor)` | `[Link Text](folder/filename.md#Anchor)`|\n| `[Link Text](filename.md)` | `[Link Text](folder/filename.md)`|\n| `[Link Text](filename.md#Anchor)` | `[Link Text](folder/filename.md#Anchor)` |\n| `![Image Alt Text](image)` | `![Image Alt Text](folder/image.png)` |\n| `![Image Alt Text](image.png)` | `![Image Alt Text](folder/image.png)` |\n| `![Image Alt Test](image \"Image Title\")` | `![Image Alt Text](folder/image.png \"Image Title\")` |\n\n\n## Absolute Links\nGiven a layout such as\n```\n- static/\n  +-- image.png\n- folder/\n  +-- document.md\n- index.md\n```\nGiven that we are entering the links into the `folder/document.md` file,\n\n|Link|Translation|\n|----|-----------|\n| `![Link Text](/static/image.png)` | `![Link Text](../static/image.png)` |\n\n# WikiLink Support\nGiven a layout such as\n```\n- folder1/\n  +-- main.md\n- folder2/\n  +-- page-name.md\n- images/\n  +-- puppy.png\n```\nand these links are entered in `folder1/main.md`, this is how wikilinks will be translated\n\n|Link|Translation|\n|----|-----------|\n| `[[Page Name]]` | `[Page Name](../folder2/page-name.md)` |\n| `![[Puppy]]` | `![Puppy](../images/puppy.png)` | `[[Page Name#Section Heading]]` | `[Page Name](../relative/path/to/page-name.md#section-heading)` |\n| `[[Page Name\\|Link Text]]` | `[Link Text](../folder2/page-name.md)` |\n| `[[Page Name#Section Heading\\|Link Text]]` | `[Link Text](../folder2/page-name.md#section-heading)` |\n\n# Attribution\nThis work is highly inspired from the following plugins:\n  - [mkdocs-autolinks-plugin](https://github.com/midnightprioriem/mkdocs-autolinks-plugin/)\n  - [mkdocs-roamlinks-plugin](https://github.com/Jackiexiao/mkdocs-roamlinks-plugin)\n  - [mkdocs-abs-rel-plugin](https://github.com/sander76/mkdocs-abs-rel-plugin)\n\n  I have combined some the features of these plugins, fixed several existing bugs, and am adding features in order to\n  provide a cohesive, up-to-date, and maintained solution for the mkdocs community.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A mkdocs plugin that makes linking to other documents easy.",
    "version": "0.3.3",
    "split_keywords": [
        "mkdocs",
        "wikilinks",
        "ezlinks",
        "obsidian",
        "roam"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "2ef9b4f08d63013e488bab78a30447e7",
                "sha256": "8307ddf354c8f0dfe44a94fe2d7524911d5a303ff9d989ddd3f950acba2606c7"
            },
            "downloads": -1,
            "filename": "mkdocs_ezlinked_plugin-0.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2ef9b4f08d63013e488bab78a30447e7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 13254,
            "upload_time": "2022-12-08T01:01:17",
            "upload_time_iso_8601": "2022-12-08T01:01:17.325898Z",
            "url": "https://files.pythonhosted.org/packages/0f/91/b879fdd4a3051f49ac9073acf58c023c025eb6f0c284adc0d141d075b610/mkdocs_ezlinked_plugin-0.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "51cd5d16b14ac8b415139e400a6921ca",
                "sha256": "f9d83f1372e26e6b9b31b4e65e131667d4800a2b3a2471f70d2d1cd8199269fe"
            },
            "downloads": -1,
            "filename": "mkdocs-ezlinked-plugin-0.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "51cd5d16b14ac8b415139e400a6921ca",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 10370,
            "upload_time": "2022-12-08T01:01:19",
            "upload_time_iso_8601": "2022-12-08T01:01:19.041299Z",
            "url": "https://files.pythonhosted.org/packages/1d/33/ab9ed623f18cbff71c3894b1d7ac2b02c6f359614bfdff18431884f14e12/mkdocs-ezlinked-plugin-0.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-08 01:01:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Mara-Li",
    "github_project": "mkdocs-ezlinks-plugin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "mkdocs",
            "specs": []
        },
        {
            "name": "dataclasses",
            "specs": [
                [
                    ">=",
                    "0.7"
                ]
            ]
        },
        {
            "name": "pygtrie",
            "specs": [
                [
                    "==",
                    "2.*"
                ]
            ]
        }
    ],
    "lcname": "mkdocs-ezlinked-plugin"
}
        
Elapsed time: 0.01510s