mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #4992 from tk0miya/4973_latex_glossary
Fix #4973: latex: glossary directive adds whitespace to each item
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -36,6 +36,7 @@ Bugs fixed
|
||||
* #4979: latex: Incorrect escaping of curly braces in index entries
|
||||
* #4956: autodoc: Failed to extract document from a subclass of the class on
|
||||
mocked module
|
||||
* #4973: latex: glossary directive adds whitespace to each item
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
||||
@@ -1555,9 +1555,12 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
def visit_term(self, node):
|
||||
# type: (nodes.Node) -> None
|
||||
self.in_term += 1
|
||||
ctx = '}] \\leavevmode' # type: unicode
|
||||
ctx = '' # type: unicode
|
||||
if node.get('ids'):
|
||||
ctx += self.hypertarget(node['ids'][0])
|
||||
ctx = '\\phantomsection'
|
||||
for node_id in node['ids']:
|
||||
ctx += self.hypertarget(node_id, anchor=False)
|
||||
ctx += '}] \\leavevmode'
|
||||
self.body.append('\\item[{')
|
||||
self.restrict_footnote(node)
|
||||
self.context.append(ctx)
|
||||
|
||||
7
tests/roots/test-glossary/conf.py
Normal file
7
tests/roots/test-glossary/conf.py
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
master_doc = 'index'
|
||||
|
||||
latex_documents = [
|
||||
(master_doc, 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report')
|
||||
]
|
||||
22
tests/roots/test-glossary/index.rst
Normal file
22
tests/roots/test-glossary/index.rst
Normal file
@@ -0,0 +1,22 @@
|
||||
test-glossary
|
||||
=============
|
||||
|
||||
.. glossary::
|
||||
:sorted:
|
||||
|
||||
boson
|
||||
Particle with integer spin.
|
||||
|
||||
*fermion*
|
||||
Particle with half-integer spin.
|
||||
|
||||
tauon
|
||||
myon
|
||||
electron
|
||||
Examples for fermions.
|
||||
|
||||
über
|
||||
Gewisse
|
||||
|
||||
änhlich
|
||||
Dinge
|
||||
@@ -1242,3 +1242,25 @@ def test_latex_nested_enumerated_list(app, status, warning):
|
||||
assert r'\setcounter{enumiii}{9}' in result
|
||||
assert r'\setcounter{enumiv}{23}' in result
|
||||
assert r'\setcounter{enumii}{2}' in result
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='glossary')
|
||||
def test_latex_glossary(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
result = (app.outdir / 'test.tex').text(encoding='utf8')
|
||||
assert (u'\\item[{änhlich\\index{änhlich|textbf}\\phantomsection'
|
||||
r'\label{\detokenize{index:term-anhlich}}}] \leavevmode' in result)
|
||||
assert (r'\item[{boson\index{boson|textbf}\phantomsection'
|
||||
r'\label{\detokenize{index:term-boson}}}] \leavevmode' in result)
|
||||
assert (r'\item[{\sphinxstyleemphasis{fermion}\index{fermion|textbf}'
|
||||
r'\phantomsection'
|
||||
r'\label{\detokenize{index:term-fermion}}}] \leavevmode' in result)
|
||||
assert (r'\item[{tauon\index{tauon|textbf}\phantomsection'
|
||||
r'\label{\detokenize{index:term-tauon}}}] \leavevmode'
|
||||
r'\item[{myon\index{myon|textbf}\phantomsection'
|
||||
r'\label{\detokenize{index:term-myon}}}] \leavevmode'
|
||||
r'\item[{electron\index{electron|textbf}\phantomsection'
|
||||
r'\label{\detokenize{index:term-electron}}}] \leavevmode' in result)
|
||||
assert (u'\\item[{über\\index{über|textbf}\\phantomsection'
|
||||
r'\label{\detokenize{index:term-uber}}}] \leavevmode' in result)
|
||||
|
||||
Reference in New Issue
Block a user