mondeja / mkdocs-include-markdown-plugin

Mkdocs Markdown includer plugin
Apache License 2.0
111 stars 20 forks source link

This plugin doesn't seem to work with the `offline` plugin from MkDocs material #195

Closed ilyagr closed 9 months ago

ilyagr commented 9 months ago

I posted a detailed report at https://github.com/squidfunk/mkdocs-material/issues/6749. I'm guessing that it's mostly the offline plugin's fault, but that's just a guess, and perhaps there's something on this side that could be changed to fix it.

Any advice or workarounds would also be appreciated. Thank you for making the plugin!

mondeja commented 9 months ago

Thanks for the detailed report.

This happens because the configuration file inheritance feature of Mkdocs works by replacing all keys of parent inherited configurations. So, in this case, plugins: ['include-markdown', ...] is replaced by plugins: ['offline'].

See mkdocs/utils/yaml.py. This can be reproduced with:

>>> import deepmerge
>>> mergedeep.merge({"plugins": ["include-markdown"]}, {"plugins": ["offline"]})
{'plugins': ['offline']}

Perhaps this can be considered as a bug or limitation of Mkdocs, but not sure if it is by design. I'm going to continue the research and open the corresponding discussion if appropiate. For now, you must consider redesigning how are you inheriting the configuration, as the current behaviour is the expected (see Configuration Inheritance).

ilyagr commented 9 months ago

You are correct. Thank you so much, I really appreciate it!

I added all the plugins to mkdocs-offline.yml file for now, might try to do something more clever later.

Please share any bugs you open, if you are indeed planning to research this further.

mondeja commented 9 months ago

Seems like is already being discussed on https://github.com/mkdocs/mkdocs/issues/3216, so closing this for now.