[snippet_var_resolver] Add plugin to resolve variables inside of snippets#36
Merged
[snippet_var_resolver] Add plugin to resolve variables inside of snippets#36
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new MkDocs plugin (snippet_var_resolver) to resolve leftover {{ variable }} placeholders in rendered HTML (after snippet injection), using variables sourced from mkdocs-macros-plugin’s include_yaml configuration.
Changes:
- Introduce
SnippetVarResolverPluginwith YAML variable loading + placeholder replacement inon_page_content. - Register the new plugin entry point and bump package version to
0.1.0a11. - Add dedicated documentation and a new test suite for the resolver behavior.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
plugins/snippet_var_resolver/plugin.py |
Implements YAML loading from macros.include_yaml and regex-based placeholder substitution on page HTML. |
pyproject.toml |
Registers the plugin entry point and bumps the project version. |
docs/snippet-var-resolver.md |
Documents the motivation, usage, and behavior/limitations of the plugin. |
tests/snippet_var_resolver/test_snippet_var_resolver.py |
Adds unit tests for dotted-path lookup, substitution behavior, and YAML include loading/merging. |
plugins/snippet_var_resolver/__init__.py |
Package marker for the new plugin module. |
tests/snippet_var_resolver/__init__.py |
Package marker for the new test module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new MkDocs plugin,
snippet_var_resolver, which resolves{{ variable }}placeholders in HTML content that remain after snippet injection, ensuring variables from YAML files are correctly rendered even when injected viapymdownx.snippets. The plugin is fully documented, registered in the project, and covered by comprehensive tests.New Plugin: Snippet Variable Resolver
SnippetVarResolverPlugininplugins/snippet_var_resolver/plugin.py, which:macrosplugin'sinclude_yamlconfig.{{ variable }}placeholders in the HTML after snippet injection, supporting dotted paths and leaving unknown variables untouched.Documentation
docs/snippet-var-resolver.mdwith usage instructions, configuration details, and notes about plugin behavior and limitations.Project Registration
pyproject.tomlunder[project.entry-points."mkdocs.plugins"].0.1.0a11to reflect the new feature.Testing
tests/snippet_var_resolver/test_snippet_var_resolver.pywith thorough unit tests for variable resolution logic, YAML loading, and integration scenarios.