EddyLuten / mkdocs-alias-plugin

An MkDocs plugin allowing links to your pages using a custom alias
MIT License
12 stars 2 forks source link

specific words cause the plugin to fail #7

Closed usulpt closed 6 months ago

usulpt commented 6 months ago

hello.

whenever I use the word "context" (upper or lowercase) in an alias definition under the frontmatter YAML of an mkdocs.yml file, the build process fails with the following error:

meta_data['alias']['text']
~~~~~~~~~~~~~~~~~~^^^^^^^^

I'm using Python 3.11, mkdocs 1.5.3 with mkdocs-material 9.4.1

thanks! Jorge

EddyLuten commented 6 months ago

Interesting, I'll take a look!

usulpt commented 6 months ago

it was really weird because I work with a few hundred files in the same folder and I was processing them automatically through another tool that inserts names of files as aliases in the same file. and everything was running fine until it hit a file called "somethingcontext.md". tested it with several files with the same results and ended up having to rename the alias to something like "ctx". maybe there's a reserved keyword, beats me, but the plugin is really useful (great work!) so I wanted to give you a heads-up anyway :)

EddyLuten commented 6 months ago

Nope, a big dumb mistake on my end caused this. It was choking on every instance of an alias with the word "text" in it since I did something like:

if 'text' in alias

Rather than:

if isinstance(alias, dict) and 'text' in alias

D'oh! Aliases can be defined as strings or as dictionaries of strings and their default titles, but I wasn't checking for the correct data type :/

I just fixed this and pushed up a new version to PyPI, v0.7.1. Just pip install it as usual, but add the --upgrade flag, which should pull the latest version.

Please let me know if this fixes the issue, and I'll close the bug!

usulpt commented 6 months ago

pretty dumb, yeah, and I should know because I made several of those in my programming life :) I hadn't even checked the code before I opened the issue, shame on me.

just tested 0.7.1 and it works fine now! thank you very much for the fix and for doing it lightning-fast!

EddyLuten commented 6 months ago

Awesome, thanks for the report!1