Ignore parts of index.rst in the latexpdf build

24 views
Skip to first unread message

Jeff Larson

unread,
Oct 4, 2019, 8:06:02 AM10/4/19
to sphinx-users
Is it possible to have Sphinx ignore part of index.rst when building the pdf with latexpdf? 

For example, my index.rst file contains (but does not begin with) the lines 


These should appear in the html that is built, but not in the PDF. I didn't see anything here:

Is it possible to tell sphinx to ignore these lines?
 

Eric Larson

unread,
Oct 4, 2019, 8:13:43 AM10/4/19
to sphinx...@googlegroups.com
You could probably solve this by ignoring the file with bad content, and then in a new file, using two consecutive `.. include` directives -- one with a `:end-before:` and the other with a `:start-after:`, after doing some labeling before and after your RST section to be ignored.


Eric


--
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 view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/8cee07ff-5278-45a0-8504-0015f9971cfb%40googlegroups.com.

Stefano David

unread,
Oct 4, 2019, 9:46:43 AM10/4/19
to sphinx-users
Hi


On Friday, 4 October 2019 14:06:02 UTC+2, Jeff Larson wrote:
Is it possible to have Sphinx ignore part of index.rst when building the pdf with latexpdf? 
Yes, it is, by using the directive only:: html before the lines you don't want to include in the (latex)pdf. Remember to indent the content that should go only in the HTML, so in your case

For example, my index.rst file contains (but does not begin with) the lines 

.. only::html
 
   .. image:: https://img.shields.io/....
      :target: https://pypi.org/....

...and so on.

As said, make sure that the .. image:: directives and their option be indented.

In case you need them in builds other than HTML (for example epub), use .. only:: html of epub

HTH,
Stefano

Jeff Larson

unread,
Oct 4, 2019, 9:49:54 AM10/4/19
to sphinx-users
Thank you very much
Reply all
Reply to author
Forward
0 new messages