Or you can use another directive do the replace first, then process the code block. We use the Jinja extension to do this on a regular basis.
Note that we are still using Sphinx 1.4.x and highlighting only works for HTML, it does not highlight in PDF output. I do not know if it has been fixed in later versions or if this matters to you. --Peter On Tuesday, October 3, 2017 at 5:37:10 PM UTC-7, Kengo TODA wrote: > > Hello sphinx-users, > > > Thanks for your support to make documentation easy. > Could you tell me how I can use substitution in code-block with code > highlight? > > > *# background* > I'm making a web page which includes sample build script: > http://spotbugs.readthedocs.io/en/latest/migration.html > > This page includes version of the latest release of our product, > and I need to update .rst file manually to realize keeping the latest > version in this page. > Let me ask how I can eliminate manual tasks like this. > > I've found that I can use substitution and sphinx.ext.extlinks help me. > It works if version exists in text or hyperlink. But in case of code-block, > I cannot use substitution. > > *# incomplete solution* > I found the solution using parsed-literal block, but it doesn't support > code highlight > so look & feel are really bad. > - https://stackoverflow.com/a/12644533/814928 > > *# known workaround* > Maybe it is possible to: > 1. write code snippet into template file with |release| and/or |version|, > 2. generate replaced text from these template, > 3. write replaced text into temporal file, and > 4. use literalinclude directive (which supports code highlight) to include > replaced text > > I wish we have better solution which can simplify document generation. > > > Thanks in advance, > Kengo TODA > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sphinx-users. For more options, visit https://groups.google.com/d/optout.
