From 84f781252f7ec44e2b13da24ea8c3e34589b414c Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 8 Nov 2018 16:32:23 +0900 Subject: [PATCH] Fix #3080: texinfo: multiline rubric is broken --- CHANGES | 1 + sphinx/writers/texinfo.py | 2 ++ tests/roots/test-markup-rubric/conf.py | 7 +++++++ tests/roots/test-markup-rubric/index.rst | 7 +++++++ tests/test_build_texinfo.py | 9 +++++++++ 5 files changed, 26 insertions(+) create mode 100644 tests/roots/test-markup-rubric/conf.py create mode 100644 tests/roots/test-markup-rubric/index.rst diff --git a/CHANGES b/CHANGES index 00e84847ba7..c242dbe69ae 100644 --- a/CHANGES +++ b/CHANGES @@ -38,6 +38,7 @@ Bugs fixed crashed * #5561: make all-pdf fails with old xindy version * #5557: quickstart: --no-batchfile isn't honored +* #3080: texinfo: multiline rubrics are broken Testing -------- diff --git a/sphinx/writers/texinfo.py b/sphinx/writers/texinfo.py index 701880a6194..a27c8c9fc84 100644 --- a/sphinx/writers/texinfo.py +++ b/sphinx/writers/texinfo.py @@ -673,9 +673,11 @@ def visit_rubric(self, node): except IndexError: rubric = self.rubrics[-1] self.body.append('\n%s ' % rubric) + self.escape_newlines += 1 def depart_rubric(self, node): # type: (nodes.Node) -> None + self.escape_newlines -= 1 self.body.append('\n\n') def visit_subtitle(self, node): diff --git a/tests/roots/test-markup-rubric/conf.py b/tests/roots/test-markup-rubric/conf.py new file mode 100644 index 00000000000..31e7a6ed4ad --- /dev/null +++ b/tests/roots/test-markup-rubric/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') +] diff --git a/tests/roots/test-markup-rubric/index.rst b/tests/roots/test-markup-rubric/index.rst new file mode 100644 index 00000000000..c2ae68a86ea --- /dev/null +++ b/tests/roots/test-markup-rubric/index.rst @@ -0,0 +1,7 @@ +test-markup-rubric +=================== + +.. rubric:: This is a rubric + +.. rubric:: This is + a multiline rubric diff --git a/tests/test_build_texinfo.py b/tests/test_build_texinfo.py index b1fd8c2a97e..204f189a61a 100644 --- a/tests/test_build_texinfo.py +++ b/tests/test_build_texinfo.py @@ -72,3 +72,12 @@ def test_texinfo(app, status, warning): assert False, 'makeinfo exited with return code %s' % retcode finally: os.chdir(cwd) + + +@pytest.mark.sphinx('texinfo', testroot='markup-rubric') +def test_texinfo_rubric(app, status, warning): + app.build() + + output = (app.outdir / 'python.texi').text() + assert '@heading This is a rubric' in output + assert '@heading This is a multiline rubric' in output