Plugin development #7474
-
Hello Everyone Context: I've seen a lot of plugins which have icons (as svg) in the resulting HTML. But I couldn't figure out how they added these to the HTML. Is there a standardized way of which I am not aware of? Are there any other resources for plugin development? So far I've found : |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @PLAYG0N,
I'm not sure if I understood the scope of this question correctly, but plugins in MkDocs should follow the event execution loop:
I didn't read Guide by Sam, but after a skim it seems to be a good introduction to the topic, but personally I would just copy a simple plugin, manually, file-by-file, and learn it this way, fixing bugs along the way ✌️ I'm not sure if you're a beginner to Python, if so, you could use these resources for a better understanding of the basics in general:
The Template is a bit outdated, as it doesn't introduce the PluginConfig approach: Note You could consider making a Markdown Extension to process the tokenized strings instead of relying on regex replacement in events and improve performance, but I never done it myself, so can't point to any direction. If your project is small or a one-off you probably shouldn't worry about performance, just focus on the simplest solution first 👌 As for plugins a short rundown to perhaps add to or repeat things from your other resources: To edit Markdown before it's rendered with Markdown Extensions you'd use
If you need to modify HTML after it's been processed by the Markdown processor then you'd use
If you need to modify other HTML outside of the Markdown content, then you'd use If this is a one-off for your project then consider to make a hook instead of a plugin: One example could be the hook used in this documentation to inject Convention icons: |
Beta Was this translation helpful? Give feedback.
Hello @PLAYG0N,
I'm not sure if I understood the scope of this question correctly, but plugins in MkDocs should follow the event execution loop:
Open up the diagram to see the flow of the loop.
I didn't read Guide by Sam, but after a skim it seems to be a good introduction to the topic, but personally I would just copy a simple plugin, manually, file-by-file, and learn it this way, fixing bugs along the way ✌️ I'm not sure if you're a beginner to Python, if so, you could use these resources for a better understanding of the basics in general: