Skip to content

Commit

Permalink
Fix sphinx-doc#3080: texinfo: multiline citations are broken
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Nov 8, 2018
1 parent 84f7812 commit feba53f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -39,6 +39,7 @@ Bugs fixed
* #5561: make all-pdf fails with old xindy version
* #5557: quickstart: --no-batchfile isn't honored
* #3080: texinfo: multiline rubrics are broken
* #3080: texinfo: multiline citations are broken

Testing
--------
Expand Down
4 changes: 3 additions & 1 deletion sphinx/writers/texinfo.py
Expand Up @@ -922,12 +922,14 @@ def visit_footnote_reference(self, node):

def visit_citation(self, node):
# type: (nodes.Node) -> None
self.body.append('\n')
for id in node.get('ids'):
self.add_anchor(id, node)
self.escape_newlines += 1

def depart_citation(self, node):
# type: (nodes.Node) -> None
pass
self.escape_newlines -= 1

def visit_citation_reference(self, node):
# type: (nodes.Node) -> None
Expand Down
7 changes: 7 additions & 0 deletions tests/roots/test-markup-citation/conf.py
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-

master_doc = 'index'

latex_documents = [
(master_doc, 'test.tex', 'The basic Sphinx documentation for testing', 'Sphinx', 'report')
]
9 changes: 9 additions & 0 deletions tests/roots/test-markup-citation/index.rst
@@ -0,0 +1,9 @@
test-markup-citation
=====================

This is a citation ref; [CITE1]_ and [CITE2]_.

.. [CITE1] This is a citation
.. [CITE2] This is
a multiline citation
12 changes: 12 additions & 0 deletions tests/test_build_texinfo.py
Expand Up @@ -81,3 +81,15 @@ def test_texinfo_rubric(app, status, warning):
output = (app.outdir / 'python.texi').text()
assert '@heading This is a rubric' in output
assert '@heading This is a multiline rubric' in output


@pytest.mark.sphinx('texinfo', testroot='markup-citation')
def test_texinfo_citation(app, status, warning):
app.builder.build_all()

output = (app.outdir / 'python.texi').text()
assert 'This is a citation ref; @ref{1,,[CITE1]} and @ref{2,,[CITE2]}.' in output
assert ('@anchor{index cite1}@anchor{1}@w{(CITE1)} \n'
'This is a citation\n') in output
assert ('@anchor{index cite2}@anchor{2}@w{(CITE2)} \n'
'This is a multiline citation\n') in output

0 comments on commit feba53f

Please sign in to comment.