mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix paragraphs in table cell doesn't work in Latex output (ref #1574)
This commit is contained in:
parent
b0f376fdb8
commit
e41f831fc4
@ -42,6 +42,7 @@ HEADER = r'''%% Generated by Sphinx.
|
||||
%(longtable)s
|
||||
\usepackage{sphinx}
|
||||
\usepackage{multirow}
|
||||
\usepackage{eqparbox}
|
||||
%(usepackages)s
|
||||
%(contentsname)s
|
||||
%(numfig_format)s
|
||||
@ -396,6 +397,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
self.in_caption = 0
|
||||
self.in_container_literal_block = 0
|
||||
self.in_term = 0
|
||||
self.in_merged_cell = 0
|
||||
self.first_document = 1
|
||||
self.this_is_the_title = 1
|
||||
self.literal_whitespace = 0
|
||||
@ -1074,6 +1076,13 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
if 'morerows' in node:
|
||||
self.remember_multirowcol[self.table.col] = node.get('morecols')
|
||||
self.table.col += node.get('morecols')
|
||||
if (('morecols' in node or 'morerows' in node) and
|
||||
(len(node) > 2 or len(node.astext().split('\n')) > 2)):
|
||||
self.in_merged_cell = 1
|
||||
self.literal_whitespace += 1
|
||||
self.body.append('\\eqparbox{%d}{\\vspace{.5\\baselineskip}\n' % id(node))
|
||||
self.pushbody([])
|
||||
context += '}'
|
||||
if isinstance(node.parent.parent, nodes.thead):
|
||||
if len(node) == 1 and isinstance(node[0], nodes.paragraph) and node.astext() == '':
|
||||
pass
|
||||
@ -1093,6 +1102,16 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
self.context.append(context)
|
||||
|
||||
def depart_entry(self, node):
|
||||
if self.in_merged_cell:
|
||||
self.in_merged_cell = 0
|
||||
self.literal_whitespace -= 1
|
||||
body = self.popbody()
|
||||
# Remove empty lines from top of merged cell
|
||||
while body and body[0] == "\n":
|
||||
body.pop(0)
|
||||
for line in body:
|
||||
line = re.sub(u'(?<!~\\\\\\\\)\n', u'~\\\\\\\\\n', line) # escape return code
|
||||
self.body.append(line)
|
||||
self.body.append(self.context.pop()) # header
|
||||
|
||||
def visit_acks(self, node):
|
||||
|
Loading…
Reference in New Issue
Block a user