Example of implementing a custom directive #701
-
I'm curious if anyone has implemented their own directives and injected them into the parser successfully. I sometimes find the built-in directives are insufficient, and have had interest in extending them. For example, the figure directive doesn't seem to allow its image to also have a link. Extending that directive to add a link option spec would be useful to me. I'm also interested in completely custom directives. Has this been described anywhere? The directive subclasses seem simple enough, but some guidance on how to inject them into the parser would help. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I believe this should be covered by https://myst-parser.readthedocs.io/en/latest/syntax/syntax.html#directives-a-block-level-extension-point |
Beta Was this translation helpful? Give feedback.
-
Here is one writeup in the EBP forum on defining custom admonitions (e.g. You could also implement a much more complex directive by creating your own Sphinx extension. This is definitely non-trivial but would give you total flexibility over the document structure etc. In that case, I'd look at the extensions defined in the EBP ecosystem to get inspiration for what is possible. |
Beta Was this translation helpful? Give feedback.
Here is one writeup in the EBP forum on defining custom admonitions (e.g.
{goodidea}
), does that help (cc @felixchenier)?You could also implement a much more complex directive by creating your own Sphinx extension. This is definitely non-trivial but would give you total flexibility over the document structure etc. In that case, I'd look at the extensions defined in the EBP ecosystem to get inspiration for what is possible.