adding role for missing envvar

13 views
Skip to first unread message

Philip Miller

unread,
Mar 2, 2016, 12:10:10 AM3/2/16
to nikola-discuss
One of the many reasons I like Nikola is because I am able to use restructuredtext and it tries to be compatible with sphinx. But one incompatibility I would like to work around is the missing role :envvar:. How can I have Nikola content that uses the :envvar: role? (At the moment at least, I am not interested in using the .. envvar directive.) For now, I would be fine with a custom envvar role that treats the contents as a literal. The reason I want this is so I can have a page that uses this role that I am able to use on my nikola blog and in sphinx documentation. So I guess my question is twofold: 1) how do I define a custom role to be used in nikola? 2) how do I keep this custom role from clashing when the content is processed by sphinx?


Roberto Alsina

unread,
Mar 2, 2016, 8:21:55 AM3/2/16
to nikola-discuss
The easy way is to do something like this in your document

.. role:: envvar

This is an envvar: :envvar:`PATH`

Which will produce something like <span class="ennvar">PATH</span>

The problem with that is that (I think) that will break when you put the same document in Sphinx because it already has a envvar role, and this collides with it.

Harder is: write the custom role in an extension. BUT there is already a sphinx_roles plugin that has all you need to do it.
OTOH I just did it ;-)

You can wait a day and reinstall that plugin, or just do this tiny change in your sphinx_roles.py and it should "Just Work":


On Wed, Mar 2, 2016 at 2:10 AM Philip Miller <pwmill...@gmail.com> wrote:
One of the many reasons I like Nikola is because I am able to use restructuredtext and it tries to be compatible with sphinx. But one incompatibility I would like to work around is the missing role :envvar:. How can I have Nikola content that uses the :envvar: role? (At the moment at least, I am not interested in using the .. envvar directive.) For now, I would be fine with a custom envvar role that treats the contents as a literal. The reason I want this is so I can have a page that uses this role that I am able to use on my nikola blog and in sphinx documentation. So I guess my question is twofold: 1) how do I define a custom role to be used in nikola? 2) how do I keep this custom role from clashing when the content is processed by sphinx?


--
You received this message because you are subscribed to the Google Groups "nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages