Merge pull request #4066 from aszekMosek/patch-1

Avoiding indent after index entries in latex
This commit is contained in:
Jean-François B 2017-09-20 10:43:20 +02:00 committed by GitHub
commit 59b4f32b38
4 changed files with 26 additions and 0 deletions

View File

@ -2008,6 +2008,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
logger.warning('unknown index entry type %s found', type)
except ValueError as err:
logger.warning(str(err))
if not node.get('inline', True):
self.body.append('\\ignorespaces ')
raise nodes.SkipNode
def visit_raw(self, node):

View File

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
master_doc = 'index'

View File

@ -0,0 +1,12 @@
test-latex-index
================
A :index:`famous` :index:`equation`:
.. math::
E = m c^2
.. index:: Einstein, relativity
and some text.

View File

@ -1020,3 +1020,12 @@ def test_latex_remote_images(app, status, warning):
assert '\\sphinxincludegraphics{{NOT_EXIST}.PNG}' not in result
assert ('WARNING: Could not fetch remote image: '
'http://example.com/NOT_EXIST.PNG [404]' in warning.getvalue())
@pytest.mark.sphinx('latex', testroot='latex-index')
def test_latex_index(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'Python.tex').text(encoding='utf8')
assert 'A \\index{famous}famous \\index{equation}equation:\n' in result
assert '\n\\index{Einstein}\\index{relativity}\\ignorespaces \nand' in result