0

In sphinx I want to have a command, which would expand differently depending on withter I'm making an html build or a latex build. Example:

.. |noindent| replace::

   .. only:: latex

      .. raw:: latex

         \noindent

   .. only:: html

      .. rst-class:: noindent

The problem is that replace can't accept multiline string: it can only accept a single line string:

.. |noindent| replace:: with this

Is there a way to have a shortcut binded to a chunk of rest code?

Edit:

One can just include the source of course:

  • ReST:

    .. include:: _noindent.rst
    
  • _noindent.rst:

    .. only:: latex
    
       .. raw:: latex
    
          \noindent
    
    .. only:: html
    
       .. rst-class:: noindent
    

but the drawback is to keep track of _noindent.rst: either setting correct link, or copying the file to every content folder.

Edit 2:

Perhaps it won't be hard for guy experienced with sphinx to add a custom directive

text with indent

.. noindent::

text with no indent

which would expand to the above code.

Adobe
  • 12,967
  • 10
  • 85
  • 126
  • You have a typo in your code. Once you write ``noindnet`` (wrong spelled) and once ``noindent``. Is this also in your productive code? Please correct it as it can be very annoying to the readers. – cezar Nov 14 '14 at 10:25
  • @cezar: Fixed that, sorry. – Adobe Nov 14 '14 at 10:26

0 Answers0