diff --git a/MANIFEST.in b/MANIFEST.in index a64eb62..d1135e9 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ include README.md include LICENSE.md include mkdocs_macros/*.md +include mkdocs_macros/py.typed diff --git a/README.md b/README.md index c7b43e3..f9b2cbc 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,20 @@ you should also add the `search` plugin. If no `plugins` entry is set, MkDocs enables `search` by default; but if you use it, then you have to declare it explicitly. +By default, undefined variables are printed to the page as-is. If you +wish for a page to fail on undefined variables, you should use the +below configuration instead: + +```yaml +plugins: + - search + - macros + on_undefined: strict +``` + +For details and more options, see the [documentation]( +https://mkdocs-macros-plugin.readthedocs.io/en/latest/troubleshooting/#what-happens-if-a-variable-is-undefined). + ### Check that it works The recommended way to check that the plugin works properly is to add the following command in one of the pages of your site (let's say `info.md`): diff --git a/mkdocs_macros/plugin.py b/mkdocs_macros/plugin.py index 00aa362..d3f5b66 100644 --- a/mkdocs_macros/plugin.py +++ b/mkdocs_macros/plugin.py @@ -373,7 +373,7 @@ def _load_yaml(self): # Paths are be relative to the project root. filename = os.path.join(self.project_dir, filename) if os.path.isfile(filename): - with open(filename) as f: + with open(filename, encoding="utf-8") as f: # load the yaml file # NOTE: for the SafeLoader argument, see: https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation content = yaml.load(f, Loader=yaml.SafeLoader) diff --git a/mkdocs_macros/py.typed b/mkdocs_macros/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py index e17626f..508ed57 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ def read_file(fname): "Read a local file" - return open(os.path.join(os.path.dirname(__file__), fname)).read() + return open(os.path.join(os.path.dirname(__file__), fname), encoding="utf-8").read() setup(