Let latex writer line trimming from depart_entry() work as before #8781

This is cosmetic as the blank line starting varwidth environment used
for merged table cells in latex output changed nothing to PDF.

Nevertheless I extended a unit test to have a multi-paragraph merged
cell using varwidth. What is important is that \sphinxAtStartPar line
itself is never followed by blank line.
This commit is contained in:
jfbu 2021-01-30 10:10:15 +01:00
parent be20f17892
commit 5b6a273825
4 changed files with 7 additions and 12 deletions

View File

@ -1163,7 +1163,8 @@ class LaTeXTranslator(SphinxTranslator):
else:
# the \sphinxAtStartPar is to allow hyphenation of first word of
# a paragraph in narrow contexts such as in a table cell
self.body.append('\n\\sphinxAtStartPar\n')
# added as two items (cf. line trimming in depart_entry())
self.body.extend(['\n', '\\sphinxAtStartPar\n'])
def depart_paragraph(self, node: Element) -> None:
self.body.append('\n')

View File

@ -11,9 +11,9 @@ grid table
+---------+ +---------+
| cell2-1 | | cell2-3 |
+ +---------+---------+
| | cell3-2 |
| | cell3-2-par1 |
+---------+ |
| cell4-1 | |
| cell4-1 | cell3-2-par2 |
+---------+---------+---------+
| cell5-1 |
+---------+---------+---------+

View File

@ -19,7 +19,6 @@ consecutive multirow at end of row (1\sphinxhyphen{}4 and 1\sphinxhyphen{}5)
\hline
\sphinxmultirow{3}{1}{%
\begin{varwidth}[t]{\sphinxcolwidth{1}{5}}
\sphinxAtStartPar
cell1\sphinxhyphen{}1
\par
@ -27,7 +26,6 @@ cell1\sphinxhyphen{}1
}%
&\sphinxmultirow{3}{2}{%
\begin{varwidth}[t]{\sphinxcolwidth{1}{5}}
\sphinxAtStartPar
cell1\sphinxhyphen{}2
\par
@ -38,7 +36,6 @@ cell1\sphinxhyphen{}2
cell1\sphinxhyphen{}3
&\sphinxmultirow{3}{4}{%
\begin{varwidth}[t]{\sphinxcolwidth{1}{5}}
\sphinxAtStartPar
cell1\sphinxhyphen{}4
\par
@ -46,7 +43,6 @@ cell1\sphinxhyphen{}4
}%
&\sphinxmultirow{2}{5}{%
\begin{varwidth}[t]{\sphinxcolwidth{1}{5}}
\sphinxAtStartPar
cell1\sphinxhyphen{}5
\par
@ -55,7 +51,6 @@ cell1\sphinxhyphen{}5
\\
\cline{3-3}\sphinxtablestrut{1}&\sphinxtablestrut{2}&\sphinxmultirow{2}{6}{%
\begin{varwidth}[t]{\sphinxcolwidth{1}{5}}
\sphinxAtStartPar
cell2\sphinxhyphen{}3
\par

View File

@ -19,7 +19,6 @@ header3
cell1\sphinxhyphen{}1
&\sphinxmultirow{2}{5}{%
\begin{varwidth}[t]{\sphinxcolwidth{1}{3}}
\sphinxAtStartPar
cell1\sphinxhyphen{}2
\par
@ -31,7 +30,6 @@ cell1\sphinxhyphen{}3
\\
\cline{1-1}\cline{3-3}\sphinxmultirow{2}{7}{%
\begin{varwidth}[t]{\sphinxcolwidth{1}{3}}
\sphinxAtStartPar
cell2\sphinxhyphen{}1
\par
@ -44,9 +42,11 @@ cell2\sphinxhyphen{}3
\cline{2-3}\sphinxtablestrut{7}&\sphinxstartmulticolumn{2}%
\sphinxmultirow{2}{9}{%
\begin{varwidth}[t]{\sphinxcolwidth{2}{3}}
\sphinxAtStartPar
cell3\sphinxhyphen{}2\sphinxhyphen{}par1
\sphinxAtStartPar
cell3\sphinxhyphen{}2
cell3\sphinxhyphen{}2\sphinxhyphen{}par2
\par
\vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}%
}%
@ -58,7 +58,6 @@ cell4\sphinxhyphen{}1
&\multicolumn{2}{l|}{\sphinxtablestrut{9}}\\
\hline\sphinxstartmulticolumn{3}%
\begin{varwidth}[t]{\sphinxcolwidth{3}{3}}
\sphinxAtStartPar
cell5\sphinxhyphen{}1
\par