Parsing inline literals

59 views
Skip to first unread message

Mark Peters

unread,
Apr 14, 2017, 10:54:56 PM4/14/17
to sphinx...@googlegroups.com
Hi,

Is it possible to parse an inline literal to replace text using substitution? 

For example, our RST doc includes values that are updated periodically such as:

The policy must be stored in the ``/etc/debsig/policies/|GPG_KEY_ID|`` directory

.. |GPG_KEY_ID| replace:: 69BE019A

The substitution text is interpreted, well, literally:


I've tried using backslash-escaped whitespace, as follows, but the second backslash escapes both the text and the second set of double-ticks:

The policy must be stored in the ``/etc/debsig/policies/\ |GPG_KEY_ID|\ `` directory


I know to use the parsed-literal directive for code blocks. Is there an option for inline literals? 

Thanks,
Mark






Komiya Takeshi

unread,
Apr 16, 2017, 3:29:26 AM4/16/17
to sphinx...@googlegroups.com
Hi,

Unfortunately, nested inline markup is not allowed in reST spec.
http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup

Thanks,
Takeshi KOMIYA
> --
> You received this message because you are subscribed to the Google Groups
> "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sphinx-users...@googlegroups.com.
> To post to this group, send email to sphinx...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sphinx-users.
> For more options, visit https://groups.google.com/d/optout.

Peter Burdine

unread,
Apr 17, 2017, 10:06:20 AM4/17/17
to sphinx-users
There are two other approaches that may work for you that I have used or seen people use:
1) Pass it through a pre-processer first to do replacements like that
2) Look into the jinja extension. 

In both cases the variables will be be replaced before docutils sees the reST.

Mark Peters

unread,
Apr 18, 2017, 8:22:49 AM4/18/17
to sphinx...@googlegroups.com
Thanks for the suggestions! Our use of substitutions is fairly limited, so we'll likely just rewrite those inline code snippets as parsed-literal blocks.
Reply all
Reply to author
Forward
0 new messages