Merge pull request #5095 from tk0miya/5091_latex_curlybrace_in_index

Fix #5091: latex: curly braces in index entries are not handled correctly
This commit is contained in:
Takeshi KOMIYA 2018-06-19 21:12:57 +09:00 committed by GitHub
commit fb7267aafe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View File

@ -30,6 +30,7 @@ Bugs fixed
* #5032: autodoc: loses the first staticmethod parameter for old styled classes
* #5036: quickstart: Typing Ctrl-U clears the whole of line
* #5066: html: "relations" sidebar is not shown by default
* #5091: latex: curly braces in index entries are not handled correctly
Testing
--------

View File

@ -1953,8 +1953,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
# type: (nodes.Node, Pattern) -> None
def escape(value):
value = self.encode(value)
value = value.replace(r'\{', r'\sphinxleftcurlybrace')
value = value.replace(r'\}', r'\sphinxrightcurlybrace')
value = value.replace(r'\{', r'{\sphinxleftcurlybrace}')
value = value.replace(r'\}', r'{\sphinxrightcurlybrace}')
return value
if not node.get('inline', True):

View File

@ -1209,7 +1209,7 @@ def test_latex_index(app, status, warning):
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
assert '\n\\index{main \\sphinxleftcurlybrace}\\ignorespaces ' in result
assert '\n\\index{main {\\sphinxleftcurlybrace}}\\ignorespaces ' in result
@pytest.mark.sphinx('latex', testroot='latex-equations')