Skip to content

Commit

Permalink
Merge branch 'master' of github.com:fralau/mkdocs_macros_plugin into …
Browse files Browse the repository at this point in the history
…master
  • Loading branch information
Laurent Franceschetti committed Jul 28, 2024
2 parents 5bec964 + 9a08f11 commit 69e7cad
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include README.md
include LICENSE.md
include mkdocs_macros/*.md
include mkdocs_macros/py.typed
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`):
Expand Down
2 changes: 1 addition & 1 deletion mkdocs_macros/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Empty file added mkdocs_macros/py.typed
Empty file.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 69e7cad

Please sign in to comment.