Skip to content

Add instant preview plugin#45

Draft
0xlukem wants to merge 9 commits intomainfrom
0xlukem/instant-prev
Draft

Add instant preview plugin#45
0xlukem wants to merge 9 commits intomainfrom
0xlukem/instant-prev

Conversation

@0xlukem
Copy link
Copy Markdown
Contributor

@0xlukem 0xlukem commented Apr 10, 2026

This pull request introduces a new MkDocs plugin, instant_preview_compat, which improves the user experience of instant previews in Material for MkDocs by ensuring previews start at meaningful article content, even when extra UI elements are present near the page title. The plugin is fully documented, added to the project configuration, and accompanied by comprehensive tests.

Key changes:

Plugin Implementation

  • Added the InstantPreviewCompatPlugin in plugins/instant_preview_compat/plugin.py, which post-processes built HTML to adjust instant preview anchors and content flow, supporting configuration for excluded selectors and internal link rewriting.
  • Registered the plugin entry point in pyproject.toml and incremented the package version to 0.1.0a12. [1] [2]
  • Created empty __init__.py files for the new plugin and its tests to ensure package/module importability. [1] [2]

Documentation

  • Added docs/instant-preview-compat.md with detailed usage instructions, configuration options, and notes on plugin behavior.
  • Updated README.md to document the new plugin in the list of included plugins and in the example configuration. [1] [2]

Testing

  • Added tests/instant_preview_compat/test_instant_preview_compat.py with comprehensive tests covering core plugin functionality, including anchor rewriting, exclusion of UI elements, and interaction with other plugins.

References:
[1] [2] [3] [4] [5] [6] [7] [8]

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a new MkDocs plugin (instant_preview_compat) that post-processes generated HTML to make Material for MkDocs instant previews start from meaningful article content (and optionally rewrites internal links to point at synthetic preview anchors), with accompanying docs and tests.

Changes:

  • Added InstantPreviewCompatPlugin plus shared helper library to inject preview-root targets and rewrite preview-sensitive links.
  • Registered the plugin as a MkDocs entry point and bumped package version to 0.1.0a12.
  • Added documentation and a dedicated test suite covering core preview/anchor behaviors and plugin interactions.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
plugins/instant_preview_compat/plugin.py Implements MkDocs plugin hooks for per-page processing and post-build link rewriting.
helper_lib/instant_preview_compat.py Core HTML parsing/mutation and link-rewrite logic used by the plugin.
tests/instant_preview_compat/test_instant_preview_compat.py Tests for anchor rewriting, exclusion/hoisting behavior, and toggle/AI-actions interactions.
docs/instant-preview-compat.md Usage/config docs for the new plugin.
README.md Adds the plugin to the documented plugin list and example configuration.
pyproject.toml Registers MkDocs entry point and bumps version.
plugins/instant_preview_compat/__init__.py Marks the plugin directory as a package.
tests/instant_preview_compat/__init__.py Marks the test directory as a package.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread helper_lib/instant_preview_compat.py Outdated
Comment thread docs/instant-preview-compat.md
@0xlukem 0xlukem marked this pull request as ready for review April 10, 2026 16:37
@0xlukem 0xlukem requested a review from eshaben April 10, 2026 23:52
@0xlukem 0xlukem marked this pull request as draft April 14, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants