New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hook / event handler needed to run after Markdown pre-processing #3260
Comments
As discussed in the pymdownx discussion, I wouldn't say there's a gap in the hooks, since the Markdown rendering process runs "atomically" from the point of view of a plugin. If you want to insert logic before/after specific pre-processors, the way to go is with a Markdown extension of your own. In other words, instead of trying to insert logic in the Markdown rendering process from a plugin hook, you should try to insert your logic using a Markdown extension. From what I understand, you don't have a requirement of using a plugin hook: it's just that it's more convenient than writing a Markdown extension? If your extension simply searches and replace contents, it shouldn't be too hard to write. Just make sure to have it run after the snippet pre-processor, then you can include this extension in |
Yes- the thing is, if we were to do a search for MkDocs plugins that contain Say there's a plugin that recognizes links that are similar but subtly different from normal Markdown links (ghm). If you have a need to access the full power of both MkDocs plugins and Markdown extensions at the same time, the plugin can and should insert its Markdown extension in The real problem is that this approach is not documented anywhere and as such has been kinda secret knowledge. |
I'm not saying
You're correct enough – I attempted to write an extension and wasn't able to actually get it to load without attempting to install it locally (which I did not attempt since I do not want this extension installed on my machine). I'm not using any of the standard tools like pyenv or similar that might resolve this specific concern since I don't really work with python outside of this context (and I've already got enough toolchains to be concerned with). I chose to use a hook since I was able to track the hook's source next to the documentation and have MkDocs respect it. Any sort of complete, integrated example site demonstrating how to load a 'hello, world' extension from source would be good to reference from the MkDocs documentation. I'll give implementing a real plugin another shot; it looks like the documentation has been updated since I was last looking at the core approach I've been taking. |
From facelessuser/pymdown-extensions#2074, it seems like
on_page_markdown
is run too early to see the completed work of snippets – meaning it seems to be impossible to access the content of included files for effect.A proposal from that thread is a new hook that runs its logic as the last preprocessor before rendering markdown content into HTML (between
on_page_markdown
andon_page_content
).Assuming this is desirable (since the trivial example in my other report exposes a gap in the standard hooks), what should a PR to address this make sure to consider? Any ideas for a hook name?
The text was updated successfully, but these errors were encountered: