Substitutions in Sphinx code blocks










28















In this reST example meant to be rendered by Sphinx, |yaco_url| doesn't get replaced because it's in a code-block:



.. |yaco_url| replace:: http://yaco.es/

You can use wget to download it:

.. code-block:: console

$ wget |yaco_url|package.tar.gz


I wonder if there is some way to force the replacement of |yaco_url| before rendering the code block.










share|improve this question



















  • 1





    This question is almost the same but doesn't work inside code blocks: stackoverflow.com/questions/1227037/…

    – Danny Navarro
    Jan 17 '12 at 16:49












  • Hey - did you find an answer to this?

    – Ztyx
    Mar 28 '12 at 22:08











  • No, I didn't. In the end I had to replace all |yaco_url| with a sed command.

    – Danny Navarro
    Mar 30 '12 at 10:35











  • If you haven't found it already, you might find the programoutput extension handy: packages.python.org/sphinxcontrib-programoutput

    – Kevin Horn
    May 8 '12 at 0:00















28















In this reST example meant to be rendered by Sphinx, |yaco_url| doesn't get replaced because it's in a code-block:



.. |yaco_url| replace:: http://yaco.es/

You can use wget to download it:

.. code-block:: console

$ wget |yaco_url|package.tar.gz


I wonder if there is some way to force the replacement of |yaco_url| before rendering the code block.










share|improve this question



















  • 1





    This question is almost the same but doesn't work inside code blocks: stackoverflow.com/questions/1227037/…

    – Danny Navarro
    Jan 17 '12 at 16:49












  • Hey - did you find an answer to this?

    – Ztyx
    Mar 28 '12 at 22:08











  • No, I didn't. In the end I had to replace all |yaco_url| with a sed command.

    – Danny Navarro
    Mar 30 '12 at 10:35











  • If you haven't found it already, you might find the programoutput extension handy: packages.python.org/sphinxcontrib-programoutput

    – Kevin Horn
    May 8 '12 at 0:00













28












28








28


3






In this reST example meant to be rendered by Sphinx, |yaco_url| doesn't get replaced because it's in a code-block:



.. |yaco_url| replace:: http://yaco.es/

You can use wget to download it:

.. code-block:: console

$ wget |yaco_url|package.tar.gz


I wonder if there is some way to force the replacement of |yaco_url| before rendering the code block.










share|improve this question
















In this reST example meant to be rendered by Sphinx, |yaco_url| doesn't get replaced because it's in a code-block:



.. |yaco_url| replace:: http://yaco.es/

You can use wget to download it:

.. code-block:: console

$ wget |yaco_url|package.tar.gz


I wonder if there is some way to force the replacement of |yaco_url| before rendering the code block.







python python-sphinx restructuredtext






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 17 '12 at 16:48







Danny Navarro

















asked Jan 11 '12 at 15:05









Danny NavarroDanny Navarro

1,91811420




1,91811420







  • 1





    This question is almost the same but doesn't work inside code blocks: stackoverflow.com/questions/1227037/…

    – Danny Navarro
    Jan 17 '12 at 16:49












  • Hey - did you find an answer to this?

    – Ztyx
    Mar 28 '12 at 22:08











  • No, I didn't. In the end I had to replace all |yaco_url| with a sed command.

    – Danny Navarro
    Mar 30 '12 at 10:35











  • If you haven't found it already, you might find the programoutput extension handy: packages.python.org/sphinxcontrib-programoutput

    – Kevin Horn
    May 8 '12 at 0:00












  • 1





    This question is almost the same but doesn't work inside code blocks: stackoverflow.com/questions/1227037/…

    – Danny Navarro
    Jan 17 '12 at 16:49












  • Hey - did you find an answer to this?

    – Ztyx
    Mar 28 '12 at 22:08











  • No, I didn't. In the end I had to replace all |yaco_url| with a sed command.

    – Danny Navarro
    Mar 30 '12 at 10:35











  • If you haven't found it already, you might find the programoutput extension handy: packages.python.org/sphinxcontrib-programoutput

    – Kevin Horn
    May 8 '12 at 0:00







1




1





This question is almost the same but doesn't work inside code blocks: stackoverflow.com/questions/1227037/…

– Danny Navarro
Jan 17 '12 at 16:49






This question is almost the same but doesn't work inside code blocks: stackoverflow.com/questions/1227037/…

– Danny Navarro
Jan 17 '12 at 16:49














Hey - did you find an answer to this?

– Ztyx
Mar 28 '12 at 22:08





Hey - did you find an answer to this?

– Ztyx
Mar 28 '12 at 22:08













No, I didn't. In the end I had to replace all |yaco_url| with a sed command.

– Danny Navarro
Mar 30 '12 at 10:35





No, I didn't. In the end I had to replace all |yaco_url| with a sed command.

– Danny Navarro
Mar 30 '12 at 10:35













If you haven't found it already, you might find the programoutput extension handy: packages.python.org/sphinxcontrib-programoutput

– Kevin Horn
May 8 '12 at 0:00





If you haven't found it already, you might find the programoutput extension handy: packages.python.org/sphinxcontrib-programoutput

– Kevin Horn
May 8 '12 at 0:00












1 Answer
1






active

oldest

votes


















23














Use the "parsed-literal" directive.



.. parsed-literal::

./home/user/somecommand-|version|


Source: https://groups.google.com/forum/?fromgroups=#!topic/sphinx-dev/ABzaUiCfO_8:






share|improve this answer


















  • 2





    This is close to my needs, though I'm still struggling with then treating the result as a code block, for proper formatting.

    – Howard M. Lewis Ship
    Dec 23 '15 at 19:24











  • @HowardM.LewisShip I'm struggling with the same issue. did you find a solution?

    – igracia
    May 10 '16 at 12:54






  • 2





    No, I never did.

    – Howard M. Lewis Ship
    Apr 18 '17 at 22:28










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f8821511%2fsubstitutions-in-sphinx-code-blocks%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









23














Use the "parsed-literal" directive.



.. parsed-literal::

./home/user/somecommand-|version|


Source: https://groups.google.com/forum/?fromgroups=#!topic/sphinx-dev/ABzaUiCfO_8:






share|improve this answer


















  • 2





    This is close to my needs, though I'm still struggling with then treating the result as a code block, for proper formatting.

    – Howard M. Lewis Ship
    Dec 23 '15 at 19:24











  • @HowardM.LewisShip I'm struggling with the same issue. did you find a solution?

    – igracia
    May 10 '16 at 12:54






  • 2





    No, I never did.

    – Howard M. Lewis Ship
    Apr 18 '17 at 22:28















23














Use the "parsed-literal" directive.



.. parsed-literal::

./home/user/somecommand-|version|


Source: https://groups.google.com/forum/?fromgroups=#!topic/sphinx-dev/ABzaUiCfO_8:






share|improve this answer


















  • 2





    This is close to my needs, though I'm still struggling with then treating the result as a code block, for proper formatting.

    – Howard M. Lewis Ship
    Dec 23 '15 at 19:24











  • @HowardM.LewisShip I'm struggling with the same issue. did you find a solution?

    – igracia
    May 10 '16 at 12:54






  • 2





    No, I never did.

    – Howard M. Lewis Ship
    Apr 18 '17 at 22:28













23












23








23







Use the "parsed-literal" directive.



.. parsed-literal::

./home/user/somecommand-|version|


Source: https://groups.google.com/forum/?fromgroups=#!topic/sphinx-dev/ABzaUiCfO_8:






share|improve this answer













Use the "parsed-literal" directive.



.. parsed-literal::

./home/user/somecommand-|version|


Source: https://groups.google.com/forum/?fromgroups=#!topic/sphinx-dev/ABzaUiCfO_8:







share|improve this answer












share|improve this answer



share|improve this answer










answered Sep 28 '12 at 17:17









trinthtrinth

2,99673038




2,99673038







  • 2





    This is close to my needs, though I'm still struggling with then treating the result as a code block, for proper formatting.

    – Howard M. Lewis Ship
    Dec 23 '15 at 19:24











  • @HowardM.LewisShip I'm struggling with the same issue. did you find a solution?

    – igracia
    May 10 '16 at 12:54






  • 2





    No, I never did.

    – Howard M. Lewis Ship
    Apr 18 '17 at 22:28












  • 2





    This is close to my needs, though I'm still struggling with then treating the result as a code block, for proper formatting.

    – Howard M. Lewis Ship
    Dec 23 '15 at 19:24











  • @HowardM.LewisShip I'm struggling with the same issue. did you find a solution?

    – igracia
    May 10 '16 at 12:54






  • 2





    No, I never did.

    – Howard M. Lewis Ship
    Apr 18 '17 at 22:28







2




2





This is close to my needs, though I'm still struggling with then treating the result as a code block, for proper formatting.

– Howard M. Lewis Ship
Dec 23 '15 at 19:24





This is close to my needs, though I'm still struggling with then treating the result as a code block, for proper formatting.

– Howard M. Lewis Ship
Dec 23 '15 at 19:24













@HowardM.LewisShip I'm struggling with the same issue. did you find a solution?

– igracia
May 10 '16 at 12:54





@HowardM.LewisShip I'm struggling with the same issue. did you find a solution?

– igracia
May 10 '16 at 12:54




2




2





No, I never did.

– Howard M. Lewis Ship
Apr 18 '17 at 22:28





No, I never did.

– Howard M. Lewis Ship
Apr 18 '17 at 22:28



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f8821511%2fsubstitutions-in-sphinx-code-blocks%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kleinkühnau

Makov (Slowakei)

Deutsches Schauspielhaus